Skip to content

Commit 168c292

Browse files
committed
minor changes and refactoring
1 parent 866dd83 commit 168c292

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

ObjectSemantics.NET/Algorithim/GavinsAlgorithim.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ internal static TemplatedContent GenerateTemplateFromFileContents(string fileCon
9898
string _replaceCode = string.Format("REPLACE_IF_CONDITION_{0}", Guid.NewGuid().ToString().ToUpper());
9999
string subBlock = templatedContent.Template.GetSubstringByIndexStartAndEnd(regexIfConditionMatch.Index + regexIfConditionMatch.Length, regexIfConditionMatchEnd.Index - 1);
100100
//#Replace Template Block with unique Code
101-
//templatedContent.Template = templatedContent.Template.ReplaceFirstOccurrence(subBlock, _replaceCode);
102101
templatedContent.Template = templatedContent.Template.ReplaceByIndexStartAndEnd(regexIfConditionMatch.Index, (regexIfConditionMatchEnd.Index - 1) + regexIfConditionMatchEnd.Length, _replaceCode);
103102
//#Append Condition Code
104103
templatedContent.ReplaceIfConditionCodes.Add(new ReplaceIfConditionCode
@@ -116,8 +115,8 @@ internal static TemplatedContent GenerateTemplateFromFileContents(string fileCon
116115
#endregion
117116

118117
#region Generate Obj Looop
119-
Match regexLoopMatch = Regex.Match(templatedContent.Template, "{{(.+?)for-each-start:(.+?)}}", RegexOptions.IgnoreCase);
120-
Match regexLoopEnd = Regex.Match(templatedContent.Template, "{{(.+?)for-each-end:(.+?)}}", RegexOptions.IgnoreCase);
118+
Match regexLoopMatch = Regex.Match(templatedContent.Template, "{{\\s*for-each-start:([^()]+?)\\s*}}", RegexOptions.IgnoreCase);
119+
Match regexLoopEnd = Regex.Match(templatedContent.Template, "{{\\s*for-each-end:([^()]+?)\\s*}}", RegexOptions.IgnoreCase);
121120
while (regexLoopMatch.Success && regexLoopEnd.Success)
122121
{
123122
int startAtIndex = templatedContent.Template.IndexOf(regexLoopMatch.Value); //Getting again index just incase it was replaced
@@ -128,7 +127,7 @@ internal static TemplatedContent GenerateTemplateFromFileContents(string fileCon
128127
string replaceCode = string.Format("REPLACE_LOOP_{0}", Guid.NewGuid().ToString().ToUpper());
129128
templatedContent.Template = Regex.Replace(templatedContent.Template, subBlock, replaceCode, RegexOptions.IgnoreCase);
130129
//Loop Target Object Name
131-
string targetObjName = regexLoopMatch.Value.Replace("{", string.Empty).Replace("}", string.Empty).Trim().Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault();
130+
string targetObjName = (regexLoopMatch.Groups.Count >= 1) ? regexLoopMatch.Groups[1].Value?.Trim()?.ToString()?.ToLower()?.Replace(" ", string.Empty) : string.Empty;
132131
//Obj
133132
ReplaceObjLoopCode replaceObjLoopCode = new ReplaceObjLoopCode { ReplaceRef = replaceCode, TargetObjectName = targetObjName };
134133
//Extra Loop Contents

0 commit comments

Comments
 (0)