Skip to content

Commit 0c1f1f5

Browse files
Update ViewCodeCombination.cs
1 parent 888d9fa commit 0c1f1f5

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

class/ViewCodeCombination.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ internal class ViewCodeCombination
2020
internal string CaseCodeTemplateValueForFullPathWithModel = "";
2121
internal string MethodCodeTemplateValue = "";
2222
internal string GlobalTemplate = "";
23+
private readonly Regex _ClassPathIsFineRegex = new Regex("[^a-zA-Z0-9_.]", RegexOptions.Compiled);
24+
private readonly Regex _ToMethodNameCleanRegex = new Regex("[^a-zA-Z0-9_]", RegexOptions.Compiled);
2325

2426
internal void Set(string FilePath, string RootDirectoryPath, int MethodIndexer)
2527
{
@@ -126,7 +128,7 @@ private void AspxTextAndCodeCombinationStandard(string AspxText, string FilePath
126128
Controller = Controller.GetTextBeforeValue("(");
127129
}
128130

129-
if (!Controller.ClassPathIsFine())
131+
if (_ClassPathIsFineRegex.IsMatch(Controller))
130132
{
131133
ErrorList.Add("Error: Controller class path is not fine in " + AspxFilePath + " file");
132134
return;
@@ -170,7 +172,7 @@ private void AspxTextAndCodeCombinationStandard(string AspxText, string FilePath
170172
Model = Model.GetTextBeforeValue("(");
171173
}
172174

173-
if (!Model.ClassPathIsFine())
175+
if (_ClassPathIsFineRegex.IsMatch(Model))
174176
{
175177
ErrorList.Add("Error: Model class path is not fine in " + AspxFilePath + " file");
176178
return;
@@ -572,7 +574,7 @@ private void AspxTextAndCodeCombinationRazor(string AspxText, string FilePath, s
572574
Controller = Controller.GetTextBeforeValue("(");
573575
}
574576

575-
if (!Controller.ClassPathIsFine())
577+
if (_ClassPathIsFineRegex.IsMatch(Controller))
576578
{
577579
ErrorList.Add("Error: Controller class path is not fine in " + AspxFilePath + " file");
578580
return;
@@ -603,7 +605,7 @@ private void AspxTextAndCodeCombinationRazor(string AspxText, string FilePath, s
603605
Model = Model.GetTextBeforeValue("(");
604606
}
605607

606-
if (!Model.ClassPathIsFine())
608+
if (_ClassPathIsFineRegex.IsMatch(Model))
607609
{
608610
ErrorList.Add("Error: Model class path is not fine in " + AspxFilePath + " file");
609611
return;
@@ -926,7 +928,7 @@ private void AspxTextAndCodeCombinationRazor(string AspxText, string FilePath, s
926928

927929
if (!TmpAspxText.Contains("*@"))
928930
{
929-
// ErrorList.Add("Error: Index @* not closed @* for code combination in " + AspxFilePath + " file");
931+
ErrorList.Add("Error: Index @* not closed @* for code combination in " + AspxFilePath + " file");
930932
break;
931933
}
932934

@@ -1519,7 +1521,7 @@ private void SetMethod(string AspxFilePath, string Controller, string Controller
15191521
AspxFilePath = AspxFilePath.GetTextBeforeLastValue(".cshtml") + ".aspx";
15201522

15211523

1522-
string FilePathToMethodName = AspxFilePath.ToMethodNameClean();
1524+
string FilePathToMethodName = _ToMethodNameCleanRegex.Replace(AspxFilePath, "_");
15231525
bool PageIsOnlyView = !ControllerIsSet;
15241526

15251527
if (!IsBreak)
@@ -1608,6 +1610,11 @@ private void SetMethod(string AspxFilePath, string Controller, string Controller
16081610
TmpMethodCodeTemplateValue += " ViewData.AddList(controller.ViewData.GetList());" + Environment.NewLine;
16091611
TmpMethodCodeTemplateValue += " if (!string.IsNullOrEmpty(controller.ViewPath))" + Environment.NewLine;
16101612
TmpMethodCodeTemplateValue += " {" + Environment.NewLine;
1613+
TmpMethodCodeTemplateValue += " if (controller.ViewPath[0] == '>')" + Environment.NewLine;
1614+
TmpMethodCodeTemplateValue += " {" + Environment.NewLine;
1615+
TmpMethodCodeTemplateValue += " string TmpViewPath = controller.ViewPath;" + Environment.NewLine;
1616+
TmpMethodCodeTemplateValue += " return SetPageLoadByPath(TmpViewPath.Remove(0, 1), context);" + Environment.NewLine;
1617+
TmpMethodCodeTemplateValue += " }" + Environment.NewLine + Environment.NewLine;
16111618
TmpMethodCodeTemplateValue += " if (controller.ViewPath != CallerViewPath)" + Environment.NewLine;
16121619
TmpMethodCodeTemplateValue += " {" + Environment.NewLine;
16131620
TmpMethodCodeTemplateValue += " if (controller.CodeBehindModel == null)" + Environment.NewLine;
@@ -1793,6 +1800,11 @@ private void SetMethod(string AspxFilePath, string Controller, string Controller
17931800
TmpMethodCodeTemplateValue += " ViewData.AddList(controller.ViewData.GetList());" + Environment.NewLine;
17941801
TmpMethodCodeTemplateValue += " if (!string.IsNullOrEmpty(controller.ViewPath))" + Environment.NewLine;
17951802
TmpMethodCodeTemplateValue += " {" + Environment.NewLine;
1803+
TmpMethodCodeTemplateValue += " if (controller.ViewPath[0] == '>')" + Environment.NewLine;
1804+
TmpMethodCodeTemplateValue += " {" + Environment.NewLine;
1805+
TmpMethodCodeTemplateValue += " string TmpViewPath = controller.ViewPath;" + Environment.NewLine;
1806+
TmpMethodCodeTemplateValue += " return SetPageLoadByPath(TmpViewPath.Remove(0, 1), context);" + Environment.NewLine;
1807+
TmpMethodCodeTemplateValue += " }" + Environment.NewLine + Environment.NewLine;
17961808
TmpMethodCodeTemplateValue += " if (controller.ViewPath != CallerViewPath)" + Environment.NewLine;
17971809
TmpMethodCodeTemplateValue += " {" + Environment.NewLine;
17981810
TmpMethodCodeTemplateValue += " if (controller.CodeBehindModel == null)" + Environment.NewLine;

0 commit comments

Comments
 (0)