public async Task <string> GetSymbolContent(SymbolData data) { string result; if (String.IsNullOrEmpty(data.SymbolZipName)) { var alobj = await GetSymbolObject(data, true); result = ALParser.Write(alobj); return(await Task.FromResult(result)); } using (Stream fs = File.OpenRead(data.Path)) { using (var zf = new ZipFile(fs)) { int i; int.TryParse(data.SymbolZipName, out i); var zipEntry = zf[i]; using (var entryStream = zf.GetInputStream(zipEntry)) { using (var zipStream = new StreamReader(entryStream)) { result = zipStream.ReadToEnd(); return(await Task.FromResult(result)); } } } } }
public void WriteBackExistingObject_UpdatedParameter() { var alobjects = ALParser.Read(testPath); var alobject = alobjects.ElementAt(1); alobject.Methods.ElementAt(0).Parameters.ElementAt(0).Name = "UpdatedParameter_NewNameGiven"; var result = ALParser.Write(alobjects); Assert.IsNotEmpty(result); Assert.IsTrue(result.Contains("UpdatedParameter_NewNameGiven")); }
public void WriteBackExistingObject_NoChange() { var alobjects = ALParser.Read(testPath); foreach (var obj in alobjects) { var result = ALParser.Write(obj); Assert.IsNotEmpty(result); } var allobjStr = ALParser.Write(alobjects); Assert.IsNotEmpty(allobjStr); }
public void WriteNewObject_FromALObjectClass() { var alobject = new ALCodeunit { Id = 81000, Name = "Test Codeunit", Methods = new List <ALMethod>() }; var method = new ALMethod { TestMethod = true, Name = "TestMethod", MethodKind = ALMethodKind.Method }; alobject.Methods.Add(method); var result = ALParser.Write(alobject); Assert.IsNotEmpty(result); }