Skip to content

Commit

Permalink
Updates before proposed refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
martonsagi committed Oct 19, 2019
1 parent 8c3ba11 commit 4b35c37
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 6 deletions.
Binary file not shown.
Binary file not shown.
47 changes: 42 additions & 5 deletions ALObjectParser.Library/Parsers/ALObjectParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,50 @@ public void GetObjectInfo(List<string> Lines, IALObject Target)
{
var items = Regex.Match(line, pattern);
var type = items.Groups[1].Value.ToEnum<ALObjectType>();
if (type != Target.Type)

switch (type)
{
//throw new FileLoadException($"This AL Object has a different type than referenced implementation. Expected: {Target.Type} -> Actual: {type}");
Target.Type = type;
case ALObjectType.table:
ALObject = new ALTable();
break;
case ALObjectType.tableextension:
ALObject = new ALTableExtension();
break;
case ALObjectType.page:
ALObject = new ALPage();
break;
case ALObjectType.pagecustomization:
ALObject = new ALPageCustomization();
break;
case ALObjectType.pageextension:
ALObject = new ALPageExtension();
break;
case ALObjectType.report:
break;
case ALObjectType.codeunit:
ALObject = new ALCodeunit();
break;
case ALObjectType.xmlport:
break;
case ALObjectType.query:
break;
case ALObjectType.controladdin:
break;
case ALObjectType.@enum:
break;
case ALObjectType.dotnet:
break;
case ALObjectType.profile:
break;
default:
break;
}

Target = ALObject;

Target.Id = int.Parse(items.Groups[2].Value);
Target.Name = items.Groups[3].Value;
Target.Name = items.Groups[3].Value.Replace("\"", "");
Target.Type = type;
}

OnGetObjectInfo(line, Target);
Expand Down Expand Up @@ -259,7 +296,7 @@ public virtual string OnWrite(IALObject Target, List<ITestFeature> Features = nu

public virtual void OnWriteObjectHeader(IndentedTextWriter writer, IALObject Target, List<ITestFeature> Features = null)
{
writer.WriteLine($"{Target.Type} {Target.Id} {Target.Name}");
writer.WriteLine($"{Target.Type} {Target.Id} {(Target.Name.Contains(' ') ? $"\"{Target.Name}\"" : Target.Name)}");
writer.WriteLine("{");
}

Expand Down
Binary file modified ALObjectParser.Library/bin/Debug/ALObjectParser.Library.1.0.0.nupkg
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion ALObjectParser.Tests/ReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void TestCodeunit_ID_Name()
var result = parser.Read(lines);

Assert.AreEqual(81000, result.Id);
Assert.AreEqual(@"""LookupValue UT Customer""", result.Name);
Assert.AreEqual(@"LookupValue UT Customer", result.Name);
}

[Test]
Expand Down

0 comments on commit 4b35c37

Please sign in to comment.