Error executing template "Designs/Swift/Paragraph/Swift_Feature.cshtml"
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at Microsoft.CodeAnalysis.CSharp.SymbolDisplayVisitor.VisitMethod(IMethodSymbol symbol)
at Microsoft.CodeAnalysis.CSharp.SymbolDisplay.ToDisplayParts(ISymbol symbol, Nullable`1 nullableAnnotationOpt, SemanticModel semanticModelOpt, Int32 positionOpt, SymbolDisplayFormat format, Boolean minimal)
at Microsoft.CodeAnalysis.CSharp.SymbolDisplay.ToDisplayParts(ISymbol symbol, SymbolDisplayFormat format)
at Microsoft.CodeAnalysis.CSharp.MessageProvider.GetErrorDisplayString(ISymbol symbol)
at Microsoft.CodeAnalysis.DiagnosticInfo.GetArgumentsToUse(IFormatProvider formatProvider)
at Microsoft.CodeAnalysis.DiagnosticInfo.GetMessage(IFormatProvider formatProvider)
at RazorEngine.Roslyn.CSharp.RoslynCompilerServiceBase.<>c.<CompileType>b__7_1(Diagnostic diag)
at System.Linq.Enumerable.<>c__DisplayClass7_0`3.<CombineSelectors>b__0(TSource x)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.String.Join(String separator, IEnumerable`1 values)
at RazorEngine.Templating.TemplateCompilationException.GetMessage(IEnumerable`1 errors, CompilationData files, ITemplateSource template)
at RazorEngine.Templating.TemplateCompilationException..ctor(IEnumerable`1 errors, CompilationData files, ITemplateSource template)
at RazorEngine.Roslyn.CSharp.RoslynCompilerServiceBase.CompileType(TypeContext context)
at RazorEngine.Templating.RazorEngineCore.CreateTemplateType(ITemplateSource razorTemplate, Type modelType)
at RazorEngine.Templating.RazorEngineCore.Compile(ITemplateKey key, Type modelType)
at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType)
at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>
2 @using System.IO
3
4 @{
5 string layout = Model.Item.GetRawValueString("Layout", "icon-top");
6 string contentPadding = Model.Item.GetRawValueString("ContentPadding", "");
7 contentPadding = contentPadding == "none" ? "" : contentPadding;
8 contentPadding = contentPadding == "small" ? "p-3 p-md-3" : contentPadding;
9 contentPadding = contentPadding == "large" ? "p-5 p-md-5" : contentPadding;
10 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
11 }
12
13 <div class="h-100 @(contentPadding)@(theme) item_@Model.Item.SystemName.ToLower()">
14 @switch (layout)
15 {
16 case "icon-top":
17 if (!string.IsNullOrEmpty(Model.Item.GetString("Link")))
18 {
19 @:<a href="@Model.Item.GetString("Link")" class="text-decoration-none d-block h-100">
20 }
21
22 <div class="d-flex flex-column gap-3 text-center mb-0-last-child">
23 <div>
24 @RenderIconAndImage()
25 </div>
26
27 @if (
28 !string.IsNullOrEmpty(Model.Item.GetString("Title")) &&
29 !Model.Item.GetBoolean("HideTitle") ||
30 !string.IsNullOrEmpty(Model.Item.GetString("Text"))
31 )
32 {
33 <div class="mb-0-last-child">
34 @RenderTitle()
35 @RenderBody()
36 </div>
37 }
38
39 </div>
40
41 if (!string.IsNullOrEmpty(Model.Item.GetString("Link")))
42 {
43 @:</a>
44 }
45 break;
46 case "icon-left":
47 if (!string.IsNullOrEmpty(Model.Item.GetString("Link")))
48 {
49 @:<a href="@Model.Item.GetString("Link")" class="text-decoration-none d-block h-100">
50 }
51
52 <div class="d-flex flex-row align-items-stretch gap-3 h-100 text-start">
53 <div class="flex-grow-0">
54 @RenderIconAndImage()
55 </div>
56
57 @if (
58 !string.IsNullOrEmpty(Model.Item.GetString("Title")) &&
59 !Model.Item.GetBoolean("HideTitle") ||
60 !string.IsNullOrEmpty(Model.Item.GetString("Text"))
61 )
62 {
63 <div class="d-flex flex-column flex-grow-1 gap-3">
64 @RenderTitle()
65 @RenderBody()
66 </div>
67 }
68
69 </div>
70
71 if (!string.IsNullOrEmpty(Model.Item.GetString("Link")))
72 {
73 @:</a>
74 }
75 break;
76 case "icon-right":
77 if (!string.IsNullOrEmpty(Model.Item.GetString("Link")))
78 {
79 @:<a href="@Model.Item.GetString("Link")" class="text-decoration-none d-block h-100">
80 }
81
82 <div class="d-flex flex-row align-items-stretch gap-3 h-100 text-end">
83 <div class="d-flex flex-column flex-grow-1 gap-3">
84 @RenderTitle()
85 @RenderBody()
86 </div>
87
88 <div class="flex-grow-0">
89 @RenderIconAndImage()
90 </div>
91 </div>
92 if (!string.IsNullOrEmpty(Model.Item.GetString("Link")))
93 {
94 @:</a>
95 }
96 break;
97 }
98 </div>
99
100 @helper RenderIconAndImage()
101 {
102 string iconSize = Model.Item.GetRawValueString("IconSize", "2");
103 string imageSrc = !string.IsNullOrEmpty(Model.Item.GetString("Image")) ? Model.Item.GetFile("Image").Path : "";
104
105 if (!string.IsNullOrEmpty(Model.Item.GetString("Image")))
106 {
107 @RenderIcon(imageSrc, iconSize)
108 }
109 else
110 {
111 string imagePath = Model.Item.GetRawValueString("Icon", "");
112
113 if (!imagePath.ToLower().Contains("none") && imagePath != "")
114 {
115 @RenderIcon(imagePath, iconSize)
116 }
117 }
118 }
119
120 @helper RenderIcon(string imagePath, string iconSize)
121 {
122 if (Path.GetExtension(imagePath).ToLower() == ".svg")
123 {
124 <div class="icon-auto" style="height: @(iconSize)px; width: @(iconSize)px;">
125 @ReadFile(imagePath)
126 </div>
127 }
128 else
129 {
130 imagePath = "/Admin/Public/GetImage.ashx?image=" + imagePath + "&height=" + iconSize + "&width=" + iconSize + "&Crop=0&Format=WebP&Quality=100";
131 string imgAltText = Model.Item.GetRawValueString("FeatureAltText", string.Empty);
132
133 <img loading="lazy" src="@imagePath" alt="@imgAltText" title="@Model.Item.GetString("Title")" style="height: @(iconSize)px; width: @(iconSize)px;">
134 }
135 }
136
137 @helper RenderTitle()
138 {
139 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "h4");
140 string headingLevel = Model.Item.GetString("HeadingLevel", "h2");
141 string headingLevelStart = $"<{headingLevel} class=\"{titleFontSize} m-0\">";
142 string headingLevelStop = $"</{headingLevel}>";
143
144 if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) && !Model.Item.GetBoolean("HideTitle"))
145 {
146 @headingLevelStart
147 @Model.Item.GetString("Title")
148 @headingLevelStop
149 }
150 }
151
152 @helper RenderBody()
153 {
154 if (!string.IsNullOrEmpty(Model.Item.GetString("Text")))
155 {
156 <p class="m-0">@Model.Item.GetString("Text")</p>
157 }
158 }
159