@@ -9,7 +9,7 @@ internal class CodeBehindLibraryCreator
99 {
1010 private List < string > ErrorList = new List < string > ( ) ;
1111 private string CaseCodeTemplateValue = "" ;
12- private string SectionTemplateValue = "" ;
12+ private string SegmentTemplateValue = "" ;
1313 private string CaseCodeTemplateValueForFullPath = "" ;
1414 private string CaseCodeTemplateValueForFullPathWithModel = "" ;
1515 private string MethodCodeTemplateValue = "" ;
@@ -106,6 +106,8 @@ private string CreateAllAspxFiles()
106106 CodeBehindViews += " private bool FoundController { get; set; } = true;" + Environment . NewLine ;
107107 CodeBehindViews += " private bool? IgnoreLayout { get; set; } = false;" + Environment . NewLine ;
108108 CodeBehindViews += " private string WebSocketId { get; set; } = \" \" ;" + Environment . NewLine ;
109+ CodeBehindViews += " private string SSEId { get; set; } = \" \" ;" + Environment . NewLine ;
110+ CodeBehindViews += " private bool? UseSSE { get; set; } = false;" + Environment . NewLine ;
109111 CodeBehindViews += " private string ResponseText { get; set; } = \" \" ;" + Environment . NewLine + Environment . NewLine ;
110112
111113 CodeBehindOptions options = new CodeBehindOptions ( ) ;
@@ -156,7 +158,7 @@ private string CreateAllAspxFiles()
156158 lock ( EmptyObjectForLock )
157159 {
158160 CaseCodeTemplateValue += combination . CaseCodeTemplateValue ;
159- SectionTemplateValue += combination . SectionTemplateValue ;
161+ SegmentTemplateValue += combination . SegmentTemplateValue ;
160162 CaseCodeTemplateValueForFullPath += combination . CaseCodeTemplateValueForFullPath ;
161163 CaseCodeTemplateValueForFullPathWithModel += combination . CaseCodeTemplateValueForFullPathWithModel ;
162164 MethodCodeTemplateValue += combination . MethodCodeTemplateValue ;
@@ -182,7 +184,7 @@ private string CreateAllAspxFiles()
182184 lock ( EmptyObjectForLock )
183185 {
184186 CaseCodeTemplateValue += combination . CaseCodeTemplateValue ;
185- SectionTemplateValue += combination . SectionTemplateValue ;
187+ SegmentTemplateValue += combination . SegmentTemplateValue ;
186188 CaseCodeTemplateValueForFullPath += combination . CaseCodeTemplateValueForFullPath ;
187189 CaseCodeTemplateValueForFullPathWithModel += combination . CaseCodeTemplateValueForFullPathWithModel ;
188190 MethodCodeTemplateValue += combination . MethodCodeTemplateValue ;
@@ -193,9 +195,11 @@ private string CreateAllAspxFiles()
193195 CodeBehindViews += " // It Works Based On Rewriting The Option File" + Environment . NewLine ;
194196 CodeBehindViews += " public string SetPageLoadByPath(string path, HttpContext context)" + Environment . NewLine ;
195197 CodeBehindViews += " {" + Environment . NewLine ;
198+ if ( options . IgnoreLayoutForPostBack )
199+ CodeBehindViews += " try{IgnoreLayoutForPostBack(context.Request.Headers);} catch(NullReferenceException){}" + Environment . NewLine + Environment . NewLine ;
196200 CodeBehindViews += " RequestPath = path;" + Environment . NewLine ;
197201 CodeBehindViews += " FoundPage = true;" + Environment . NewLine + Environment . NewLine ;
198- CodeBehindViews += SectionTemplateValue + "/*{SectionTemplateValue }*/" + Environment . NewLine ;
202+ CodeBehindViews += SegmentTemplateValue + "/*{SegmentTemplateValue }*/" + Environment . NewLine ;
199203 CodeBehindViews += " switch (path)" + Environment . NewLine ;
200204 CodeBehindViews += " {" + Environment . NewLine ;
201205 CodeBehindViews += CaseCodeTemplateValue + Environment . NewLine + "/*{CaseCodeTemplateValue}*/" + Environment . NewLine ;
@@ -207,6 +211,8 @@ private string CreateAllAspxFiles()
207211 CodeBehindViews += " // Load All Page By Full Path, This Method Load Break Page And Does Not Apply Rewrite" + Environment . NewLine ;
208212 CodeBehindViews += " public string SetPageLoadByFullPath(string path, HttpContext context, string PageReturnValue = \" \" )" + Environment . NewLine ;
209213 CodeBehindViews += " {" + Environment . NewLine ;
214+ if ( options . IgnoreLayoutForPostBack )
215+ CodeBehindViews += " try{IgnoreLayoutForPostBack(context.Request.Headers);} catch(NullReferenceException){}" + Environment . NewLine + Environment . NewLine ;
210216 CodeBehindViews += " RequestPath = path;" + Environment . NewLine ;
211217 CodeBehindViews += " FoundPage = true;" + Environment . NewLine + Environment . NewLine ;
212218 CodeBehindViews += " switch (path)" + Environment . NewLine ;
@@ -220,6 +226,8 @@ private string CreateAllAspxFiles()
220226 CodeBehindViews += " // Load All Page By Full Path With Model, This Method Load Break Page And Does Not Apply Rewrite" + Environment . NewLine ;
221227 CodeBehindViews += " public string SetPageLoadByFullPathWithModel(string path, HttpContext context, string PageReturnValue = \" \" , object model = null)" + Environment . NewLine ;
222228 CodeBehindViews += " {" + Environment . NewLine ;
229+ if ( options . IgnoreLayoutForPostBack )
230+ CodeBehindViews += " try{IgnoreLayoutForPostBack(context.Request.Headers);} catch(NullReferenceException){}" + Environment . NewLine + Environment . NewLine ;
223231 CodeBehindViews += " RequestPath = path;" + Environment . NewLine ;
224232 CodeBehindViews += " FoundPage = true;" + Environment . NewLine + Environment . NewLine ;
225233 CodeBehindViews += " switch (path)" + Environment . NewLine ;
@@ -254,7 +262,7 @@ private string CreateAllAspxFiles()
254262 CodeBehindViews += " return SetPageLoadByFullPath(path, null, \" \" );" + Environment . NewLine ;
255263 CodeBehindViews += " }" + Environment . NewLine + Environment . NewLine ;
256264
257- CodeBehindViews += " public string RunController(HttpContext context, string ViewPath, object ModelClass, CodeBehind.HtmlData.NameValueCollection ViewData, string DownloadFilePath, bool? IgnoreLayout, string WebFormsValue, string? WebSocketId)" + Environment . NewLine ;
265+ CodeBehindViews += " public string RunController(HttpContext context, string ViewPath, object ModelClass, CodeBehind.HtmlData.NameValueCollection ViewData, string DownloadFilePath, bool? IgnoreLayout, string WebFormsValue, string? WebSocketId, string? SSEId, bool? UseSSE )" + Environment . NewLine ;
258266 CodeBehindViews += " {" + Environment . NewLine ;
259267 CodeBehindViews += " if (!string.IsNullOrEmpty(DownloadFilePath))" + Environment . NewLine ;
260268 CodeBehindViews += " {" + Environment . NewLine ;
@@ -271,6 +279,12 @@ private string CreateAllAspxFiles()
271279 CodeBehindViews += " if (WebSocketId != null)" + Environment . NewLine ;
272280 CodeBehindViews += " this.WebSocketId = WebSocketId;" + Environment . NewLine + Environment . NewLine ;
273281
282+ CodeBehindViews += " if (SSEId != null)" + Environment . NewLine ;
283+ CodeBehindViews += " this.SSEId = SSEId;" + Environment . NewLine + Environment . NewLine ;
284+
285+ CodeBehindViews += " if (UseSSE != null)" + Environment . NewLine ;
286+ CodeBehindViews += " this.UseSSE = UseSSE;" + Environment . NewLine + Environment . NewLine ;
287+
274288 CodeBehindViews += " if (ViewPath[0] == '>')" + Environment . NewLine ;
275289 CodeBehindViews += " {" + Environment . NewLine ;
276290 CodeBehindViews += " string TmpViewPath = ViewPath;" + Environment . NewLine ;
@@ -285,6 +299,8 @@ private string CreateAllAspxFiles()
285299
286300 CodeBehindViews += " public string RunControllerName(string ControllerClass, HttpContext context, bool IsDefaultController, bool BreakDefaultInSwitch)" + Environment . NewLine ;
287301 CodeBehindViews += " {" + Environment . NewLine ;
302+ if ( options . IgnoreLayoutForPostBack )
303+ CodeBehindViews += " try{IgnoreLayoutForPostBack(context.Request.Headers);} catch(NullReferenceException){}" + Environment . NewLine + Environment . NewLine ;
288304 CodeBehindViews += " string TmpViewPath = \" \" ;" + Environment . NewLine ;
289305 CodeBehindViews += " switch (ControllerClass)" + Environment . NewLine ;
290306 CodeBehindViews += " {" + Environment . NewLine ;
@@ -317,6 +333,26 @@ private string CreateAllAspxFiles()
317333 CodeBehindViews += " return WebSocketId;" + Environment . NewLine ;
318334 CodeBehindViews += " }" + Environment . NewLine + Environment . NewLine ;
319335
336+ CodeBehindViews += " public void SetSSEId(string Id)" + Environment . NewLine ;
337+ CodeBehindViews += " {" + Environment . NewLine ;
338+ CodeBehindViews += " SSEId = Id;" + Environment . NewLine ;
339+ CodeBehindViews += " }" + Environment . NewLine + Environment . NewLine ;
340+
341+ CodeBehindViews += " public string GetSSEId()" + Environment . NewLine ;
342+ CodeBehindViews += " {" + Environment . NewLine ;
343+ CodeBehindViews += " return SSEId;" + Environment . NewLine ;
344+ CodeBehindViews += " }" + Environment . NewLine + Environment . NewLine ;
345+
346+ CodeBehindViews += " public void EnableSSE()" + Environment . NewLine ;
347+ CodeBehindViews += " {" + Environment . NewLine ;
348+ CodeBehindViews += " UseSSE = true;" + Environment . NewLine ;
349+ CodeBehindViews += " }" + Environment . NewLine + Environment . NewLine ;
350+
351+ CodeBehindViews += " public bool? GetUseSSE()" + Environment . NewLine ;
352+ CodeBehindViews += " {" + Environment . NewLine ;
353+ CodeBehindViews += " return UseSSE;" + Environment . NewLine ;
354+ CodeBehindViews += " }" + Environment . NewLine + Environment . NewLine ;
355+
320356 CodeBehindViews += " public bool ControllerHasFound()" + Environment . NewLine ;
321357 CodeBehindViews += " {" + Environment . NewLine ;
322358 CodeBehindViews += " return FoundController;" + Environment . NewLine ;
@@ -413,6 +449,32 @@ private string CreateAllAspxFiles()
413449 CodeBehindViews += " await CodeBehindMiddlewareExtensions.WebSocketsBroadcastAsync(context, Message, \" \" , \" \" , ClientId, IgnoreThis);" + Environment . NewLine ;
414450 CodeBehindViews += " }" + Environment . NewLine + Environment . NewLine ;
415451
452+ CodeBehindViews += " // SSE Broadcast" + Environment . NewLine ;
453+ CodeBehindViews += " public void BroadcastSSE(HttpContext context, string Message, bool IgnoreThis = false)" + Environment . NewLine ;
454+ CodeBehindViews += " {" + Environment . NewLine ;
455+ CodeBehindViews += " CodeBehindMiddlewareExtensions.SSEsBroadcast(context, Message, \" \" , \" \" , \" \" , IgnoreThis);" + Environment . NewLine ;
456+ CodeBehindViews += " }" + Environment . NewLine + Environment . NewLine ;
457+
458+ CodeBehindViews += " public void BroadcastSSE(HttpContext context, string Message, string RoleName, string Id, string ClientId, bool IgnoreThis = false)" + Environment . NewLine ;
459+ CodeBehindViews += " {" + Environment . NewLine ;
460+ CodeBehindViews += " CodeBehindMiddlewareExtensions.SSEsBroadcast(context, Message, RoleName, Id, ClientId, IgnoreThis);" + Environment . NewLine ;
461+ CodeBehindViews += " }" + Environment . NewLine + Environment . NewLine ;
462+
463+ CodeBehindViews += " public void BroadcastSSEForRole(HttpContext context, string Message, string RoleName, bool IgnoreThis = false)" + Environment . NewLine ;
464+ CodeBehindViews += " {" + Environment . NewLine ;
465+ CodeBehindViews += " CodeBehindMiddlewareExtensions.SSEsBroadcast(context, Message, RoleName, \" \" , \" \" , IgnoreThis);" + Environment . NewLine ;
466+ CodeBehindViews += " }" + Environment . NewLine + Environment . NewLine ;
467+
468+ CodeBehindViews += " public void BroadcastSSEForSSEId(HttpContext context, string Message, string Id, bool IgnoreThis = false)" + Environment . NewLine ;
469+ CodeBehindViews += " {" + Environment . NewLine ;
470+ CodeBehindViews += " CodeBehindMiddlewareExtensions.SSEsBroadcast(context, Message, \" \" , Id, \" \" , IgnoreThis);" + Environment . NewLine ;
471+ CodeBehindViews += " }" + Environment . NewLine + Environment . NewLine ;
472+
473+ CodeBehindViews += " public void BroadcastSSEForClientId(HttpContext context, string Message, string ClientId, bool IgnoreThis = false)" + Environment . NewLine ;
474+ CodeBehindViews += " {" + Environment . NewLine ;
475+ CodeBehindViews += " CodeBehindMiddlewareExtensions.SSEsBroadcast(context, Message, \" \" , \" \" , ClientId, IgnoreThis);" + Environment . NewLine ;
476+ CodeBehindViews += " }" + Environment . NewLine + Environment . NewLine ;
477+
416478 CodeBehindViews += " private void Download(HttpContext context, string FilePath)" + Environment . NewLine ;
417479 CodeBehindViews += " {" + Environment . NewLine ;
418480 CodeBehindViews += " long FileSize = new FileInfo(FilePath).Length;" + Environment . NewLine ;
@@ -643,12 +705,18 @@ private string FillAssemblyControllerCase(Assembly assembly, string EntryAssembl
643705 }
644706
645707 ReturnValue += " " + NameSpace + TmpClass . Name + " " + ClassName + " = new " + NameSpace + TmpClass . Name + "();" + Environment . NewLine ;
646- ReturnValue += " " + ClassName + ".FillSection (context, \" /\" + ControllerClass);" + Environment . NewLine ;
708+ ReturnValue += " " + ClassName + ".FillSegment (context, \" /\" + ControllerClass);" + Environment . NewLine ;
647709 ReturnValue += " " + ClassName + ".PageLoad(context);" + Environment . NewLine ;
648710 ReturnValue += " this.WebFormsValue += " + ClassName + ".WebFormsValue;" + Environment . NewLine + Environment . NewLine ;
649711
650712 ReturnValue += " if (" + ClassName + ".WebSocketId != null)" + Environment . NewLine ;
651- ReturnValue += " this.WebSocketId = " + ClassName + ".WebSocketId;" + Environment . NewLine ;
713+ ReturnValue += " this.WebSocketId = " + ClassName + ".WebSocketId;" + Environment . NewLine + Environment . NewLine ;
714+
715+ ReturnValue += " if (" + ClassName + ".SSEId != null)" + Environment . NewLine ;
716+ ReturnValue += " this.SSEId = " + ClassName + ".SSEId;" + Environment . NewLine + Environment . NewLine ;
717+
718+ ReturnValue += " if (" + ClassName + ".UseSSE != null)" + Environment . NewLine ;
719+ ReturnValue += " this.UseSSE = " + ClassName + ".UseSSE;" + Environment . NewLine ;
652720
653721 ReturnValue += Environment . NewLine ;
654722
@@ -665,7 +733,7 @@ private string FillAssemblyControllerCase(Assembly assembly, string EntryAssembl
665733 ReturnValue += " }" + Environment . NewLine ;
666734 ReturnValue += " else" + Environment . NewLine ;
667735 ReturnValue += " {" + Environment . NewLine ;
668- ReturnValue += " string ControllerReturnValue = " + ClassName + ".ResponseText + RunController(context, " + ClassName + ".ViewPath, " + ClassName + ".CodeBehindModel, " + ClassName + ".ViewData, " + ClassName + ".DownloadFilePath, " + ClassName + ".IgnoreLayout, " + ClassName + ".WebFormsValue, " + ClassName + ".WebSocketId);" + Environment . NewLine ;
736+ ReturnValue += " string ControllerReturnValue = " + ClassName + ".ResponseText + RunController(context, " + ClassName + ".ViewPath, " + ClassName + ".CodeBehindModel, " + ClassName + ".ViewData, " + ClassName + ".DownloadFilePath, " + ClassName + ".IgnoreLayout, " + ClassName + ".WebFormsValue, " + ClassName + ".WebSocketId, " + ClassName + ".SSEId, " + ClassName + ".UseSSE );" + Environment . NewLine ;
669737 ReturnValue += " cache.SetControllerCache(\" " + TmpClass . Name + "\" + cbcc.CacheFilter, ControllerReturnValue, " + ControllerCache . Duration + ");" + Environment . NewLine ;
670738 ReturnValue += " return ControllerReturnValue;" + Environment . NewLine ;
671739 ReturnValue += " }" + Environment . NewLine ;
@@ -676,7 +744,7 @@ private string FillAssemblyControllerCase(Assembly assembly, string EntryAssembl
676744 ReturnValue += " if (" + ClassName + ".IgnoreViewAndModel)" + Environment . NewLine ;
677745 ReturnValue += " TmpViewPath = \" \" ;" + Environment . NewLine + Environment . NewLine ;
678746
679- ReturnValue += " return " + ClassName + ".ResponseText + RunController(context, TmpViewPath, " + ClassName + ".CodeBehindModel, " + ClassName + ".ViewData, " + ClassName + ".DownloadFilePath, " + ClassName + ".IgnoreLayout, " + ClassName + ".WebFormsValue, " + ClassName + ".WebSocketId);" + Environment . NewLine + Environment . NewLine ;
747+ ReturnValue += " return " + ClassName + ".ResponseText + RunController(context, TmpViewPath, " + ClassName + ".CodeBehindModel, " + ClassName + ".ViewData, " + ClassName + ".DownloadFilePath, " + ClassName + ".IgnoreLayout, " + ClassName + ".WebFormsValue, " + ClassName + ".WebSocketId, " + ClassName + ".SSEId, " + ClassName + ".UseSSE );" + Environment . NewLine + Environment . NewLine ;
680748 }
681749
682750 ReturnValue += "/*{CaseCodeTemplateValueForControllerName}*/" + Environment . NewLine ;
@@ -688,7 +756,7 @@ private string FillDefaultAssemblyControllerCase()
688756 {
689757 string ReturnValue = "" ;
690758
691- if ( StaticObject . UseDefaultController && StaticObject . UseSectionInDefaultController )
759+ if ( StaticObject . UseDefaultController && StaticObject . UseSegmentInDefaultController )
692760 {
693761 ReturnValue += " default:" + Environment . NewLine ;
694762 ReturnValue += " if (!BreakDefaultInSwitch)" + Environment . NewLine ;
0 commit comments