diff --git a/.vs/LoadXMLFile.git/FileContentIndex/1c61d131-f77f-43c4-9d94-f1f1a5613de0.vsidx b/.vs/LoadXMLFile.git/FileContentIndex/1c61d131-f77f-43c4-9d94-f1f1a5613de0.vsidx deleted file mode 100644 index d3061b9..0000000 Binary files a/.vs/LoadXMLFile.git/FileContentIndex/1c61d131-f77f-43c4-9d94-f1f1a5613de0.vsidx and /dev/null differ diff --git a/.vs/LoadXMLFile.git/FileContentIndex/485d5ec1-0bc1-4f29-9061-8810e8100694.vsidx b/.vs/LoadXMLFile.git/FileContentIndex/485d5ec1-0bc1-4f29-9061-8810e8100694.vsidx deleted file mode 100644 index 3b6c4ef..0000000 Binary files a/.vs/LoadXMLFile.git/FileContentIndex/485d5ec1-0bc1-4f29-9061-8810e8100694.vsidx and /dev/null differ diff --git a/.vs/LoadXMLFile.git/FileContentIndex/b52fdf0f-98b8-4894-8345-6534e51823bc.vsidx b/.vs/LoadXMLFile.git/FileContentIndex/b52fdf0f-98b8-4894-8345-6534e51823bc.vsidx new file mode 100644 index 0000000..4db3e28 Binary files /dev/null and b/.vs/LoadXMLFile.git/FileContentIndex/b52fdf0f-98b8-4894-8345-6534e51823bc.vsidx differ diff --git a/.vs/LoadXMLFile.git/FileContentIndex/c096ac48-9dfc-4cab-9439-fc75e333c3bf.vsidx b/.vs/LoadXMLFile.git/FileContentIndex/c096ac48-9dfc-4cab-9439-fc75e333c3bf.vsidx new file mode 100644 index 0000000..097c4ac Binary files /dev/null and b/.vs/LoadXMLFile.git/FileContentIndex/c096ac48-9dfc-4cab-9439-fc75e333c3bf.vsidx differ diff --git a/.vs/LoadXMLFile.git/FileContentIndex/2362b8fd-305d-4d49-8058-e0f1b1b5f30b.vsidx b/.vs/LoadXMLFile.git/FileContentIndex/e171802b-a722-44b0-9c21-82a492ced721.vsidx similarity index 100% rename from .vs/LoadXMLFile.git/FileContentIndex/2362b8fd-305d-4d49-8058-e0f1b1b5f30b.vsidx rename to .vs/LoadXMLFile.git/FileContentIndex/e171802b-a722-44b0-9c21-82a492ced721.vsidx diff --git a/.vs/LoadXMLFile.git/v17/.suo b/.vs/LoadXMLFile.git/v17/.suo index aec39b8..880ab5e 100644 Binary files a/.vs/LoadXMLFile.git/v17/.suo and b/.vs/LoadXMLFile.git/v17/.suo differ diff --git a/LoadXMLFile/LoadXMLFile.cs b/LoadXMLFile/LoadXMLFile.cs index e6ed0a0..b580c8b 100644 --- a/LoadXMLFile/LoadXMLFile.cs +++ b/LoadXMLFile/LoadXMLFile.cs @@ -131,7 +131,7 @@ namespace Eugen.ESystem.IO // Das Dokument in eine neue XElement-Instanz laden XElement rootElement = XElement.Load(FileName); - //Nur wenn das 'rootElement' so beginnt wie 'Topi' heißt oder 'LoadAllValues' 'Yes' ist, dann die Elemente laden + //Nur wenn das 'rootElement' so beginnt wie 'Topic' heißt oder 'LoadAllValues' 'Yes' ist, dann die Elemente laden if (rootElement.ToString().Remove(rootElement.ToString().IndexOf(" ")) == "<" + Topic || LoadAllValues == LoadAll.Yes) { // Auflistung für die Gruppe erzeugen @@ -141,10 +141,17 @@ namespace Eugen.ESystem.IO //var personElements = rootElement.Elements(Group); var groupElements = rootElement.Elements(); + if (LoadAllValues == LoadAll.Yes) + { + Group = ""; + } + if (String.IsNullOrEmpty(Group)) { string[] temp = new string[5]; + List lgroups = new List(); + List lid = new List(); List lkeys = new List(); List lvalues = new List(); List lstandard = new List(); @@ -178,17 +185,24 @@ namespace Eugen.ESystem.IO Group = ExtractGroup(temp); Key = ExtractKey(temp); + lgroups.Add(ExtractGroup(temp)); + lid.Add(ExtractId(temp)); + lkeys.Add(ExtractKey(temp)); lvalues.Add(ExtractValue(temp)); lstandard.Add(ExtractStandard(temp)); } } - string[,] values = new string[lvalues.Count, 3]; + string[,] values = new string[lvalues.Count, 5]; int standard = 0; for (int i = 0; i < lvalues.Count; i++) { - values[i, 2] = lvalues[i]; + values[i, 0] = lgroups[i]; + values[i, 1] = lid[i]; + values[i, 2] = lkeys[i]; + values[i, 3] = lvalues[i]; + values[i, 4] = lstandard[i]; if (lstandard[i] == "yes") { @@ -210,6 +224,9 @@ namespace Eugen.ESystem.IO Topics group = new Topics(); groups.Add(group); + //Den Gruppennamen extrahieren + group.GroupName = groupElement.ToString().Remove(groupElement.ToString().IndexOf(" ")).Remove(0, 1); + //Das Attribut id einlesen XAttribute idAttribute = groupElement.Attribute("Id"); if (idAttribute != null) @@ -248,6 +265,11 @@ namespace Eugen.ESystem.IO return temp[0].Remove(0, 1); } + private string ExtractId(string[] temp) + { + return temp[1].Remove(temp[1].LastIndexOf("\"")).Remove(0, 4); + } + private string ExtractKey(string[] temp) { return temp[2].Remove(temp[2].IndexOf("=")); @@ -265,13 +287,14 @@ namespace Eugen.ESystem.IO private void DataPreperation(List groups) { - string[,] values = new string[groups.Count, 3]; + string[,] values = new string[groups.Count, 4]; for (int i = 0; i < groups.Count; i++) { - values[i, 0] = groups[i].Id; - values[i, 1] = groups[i].Key; - values[i, 2] = groups[i].Standard; + values[i, 0] = groups[i].GroupName; + values[i, 1] = groups[i].Id; + values[i, 2] = groups[i].Key; + values[i, 3] = groups[i].Standard; if (groups[i].Standard == "yes") { @@ -285,6 +308,7 @@ namespace Eugen.ESystem.IO class Topics { + public string GroupName; public string Id; public string Key; public string Standard; diff --git a/LoadXMLFile/bin/Debug/heloxmlf.dll b/LoadXMLFile/bin/Debug/heloxmlf.dll index 1c6e17e..0644e58 100644 Binary files a/LoadXMLFile/bin/Debug/heloxmlf.dll and b/LoadXMLFile/bin/Debug/heloxmlf.dll differ diff --git a/LoadXMLFile/bin/Debug/heloxmlf.pdb b/LoadXMLFile/bin/Debug/heloxmlf.pdb index 2e4f4d6..9d0a800 100644 Binary files a/LoadXMLFile/bin/Debug/heloxmlf.pdb and b/LoadXMLFile/bin/Debug/heloxmlf.pdb differ diff --git a/LoadXMLFile/obj/Debug/heloxmlf.dll b/LoadXMLFile/obj/Debug/heloxmlf.dll index 1c6e17e..0644e58 100644 Binary files a/LoadXMLFile/obj/Debug/heloxmlf.dll and b/LoadXMLFile/obj/Debug/heloxmlf.dll differ diff --git a/LoadXMLFile/obj/Debug/heloxmlf.pdb b/LoadXMLFile/obj/Debug/heloxmlf.pdb index 2e4f4d6..9d0a800 100644 Binary files a/LoadXMLFile/obj/Debug/heloxmlf.pdb and b/LoadXMLFile/obj/Debug/heloxmlf.pdb differ diff --git a/Test_LoadXMLFile/Form1.Designer.cs b/Test_LoadXMLFile/Form1.Designer.cs index 67eec1c..afaab66 100644 --- a/Test_LoadXMLFile/Form1.Designer.cs +++ b/Test_LoadXMLFile/Form1.Designer.cs @@ -33,7 +33,9 @@ this.labelProgramInfo = new System.Windows.Forms.Label(); this.groupBoxDLLInfo = new System.Windows.Forms.GroupBox(); this.labelDLLInfo = new System.Windows.Forms.Label(); - this.labelResult = new System.Windows.Forms.Label(); + this.labelResult1 = new System.Windows.Forms.Label(); + this.labelResult2 = new System.Windows.Forms.Label(); + this.checkBoxLoadAllValues = new System.Windows.Forms.CheckBox(); this.groupBoxProgramInfo.SuspendLayout(); this.groupBoxDLLInfo.SuspendLayout(); this.SuspendLayout(); @@ -88,21 +90,42 @@ this.labelDLLInfo.TabIndex = 0; this.labelDLLInfo.Text = "..."; // - // labelResult + // labelResult1 // - this.labelResult.AutoSize = true; - this.labelResult.Location = new System.Drawing.Point(12, 13); - this.labelResult.Name = "labelResult"; - this.labelResult.Size = new System.Drawing.Size(16, 13); - this.labelResult.TabIndex = 13; - this.labelResult.Text = "..."; + this.labelResult1.AutoSize = true; + this.labelResult1.Location = new System.Drawing.Point(12, 13); + this.labelResult1.Name = "labelResult1"; + this.labelResult1.Size = new System.Drawing.Size(16, 13); + this.labelResult1.TabIndex = 13; + this.labelResult1.Text = "...\r\n"; + // + // labelResult2 + // + this.labelResult2.AutoSize = true; + this.labelResult2.Location = new System.Drawing.Point(410, 26); + this.labelResult2.Name = "labelResult2"; + this.labelResult2.Size = new System.Drawing.Size(16, 13); + this.labelResult2.TabIndex = 14; + this.labelResult2.Text = "..."; + // + // checkBoxLoadAllValues + // + this.checkBoxLoadAllValues.AutoSize = true; + this.checkBoxLoadAllValues.Location = new System.Drawing.Point(12, 264); + this.checkBoxLoadAllValues.Name = "checkBoxLoadAllValues"; + this.checkBoxLoadAllValues.Size = new System.Drawing.Size(97, 17); + this.checkBoxLoadAllValues.TabIndex = 15; + this.checkBoxLoadAllValues.Text = "Load all values"; + this.checkBoxLoadAllValues.UseVisualStyleBackColor = true; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.labelResult); + this.Controls.Add(this.checkBoxLoadAllValues); + this.Controls.Add(this.labelResult2); + this.Controls.Add(this.labelResult1); this.Controls.Add(this.groupBoxProgramInfo); this.Controls.Add(this.groupBoxDLLInfo); this.Controls.Add(this.buttonShowInfo); @@ -125,7 +148,9 @@ private System.Windows.Forms.Label labelProgramInfo; private System.Windows.Forms.GroupBox groupBoxDLLInfo; private System.Windows.Forms.Label labelDLLInfo; - private System.Windows.Forms.Label labelResult; + private System.Windows.Forms.Label labelResult1; + private System.Windows.Forms.Label labelResult2; + private System.Windows.Forms.CheckBox checkBoxLoadAllValues; } } diff --git a/Test_LoadXMLFile/Form1.cs b/Test_LoadXMLFile/Form1.cs index 0faab4e..d0baebc 100644 --- a/Test_LoadXMLFile/Form1.cs +++ b/Test_LoadXMLFile/Form1.cs @@ -126,46 +126,74 @@ namespace Test_LoadXMLFile load.Group = "Management"; load.Key = "Method"; //load.LoadAllValues = LoadXMLFile.LoadAll.Yes; //Es werden alle Elemente geladen - load.LoadAllValues = LoadXMLFile.LoadAll.No; //Es werden nur die Elemente geladen, die unter 'Group' gespeichert sind - load.Load(); + //load.LoadAllValues = LoadXMLFile.LoadAll.No; //Es werden nur die Elemente geladen, die unter 'Group' gespeichert sind + //load.Load(); - if (load.Values != null) + if (checkBoxLoadAllValues.Checked) { - labelResult.Text = Ausgabe(load.FileName, load.Topic, load.Group, load.Key, load.Values); - } + load.LoadAllValues = LoadXMLFile.LoadAll.Yes; //Es werden alle Elemente geladen + load.Load(); - load.Group = "NX"; - load.Key = "Version"; - load.Load(); - - if (load.Values != null) - { - labelResult.Text += Ausgabe2(load.Group, load.Key, load.Values); + if (load.Values != null) + { + labelResult1.Text = Ausgabe("Yes", load.FileName, load.Topic, load.Group, load.Key, load.Values); + labelResult2.Text = ""; + } } else { - labelResult.Text = "Keine Werte"; + load.LoadAllValues = LoadXMLFile.LoadAll.No; //Es werden nur die Elemente geladen, die unter 'Group' gespeichert sind + load.Load(); + + if (load.Values != null) + { + labelResult1.Text = Ausgabe1(load.FileName, load.Topic, load.Group, load.Key, load.Values); + } + + //Neue Gruppe setzen + load.Group = "NX"; + load.Key = "Version"; + load.Load(); + + if (load.Values != null) + { + labelResult2.Text = Ausgabe2(load.Group, load.Key, load.Values); + } + else + { + labelResult1.Text = "Keine Werte"; + labelResult2.Text = ""; + } } } - private string Ausgabe(string fileName, string topic, string group, string key, string[,] values) + private string Ausgabe(string loadAll, string fileName, string topic, string group, string key, string[,] values) { string result = ""; result = "Filename: " + fileName; result += "\r\nTopic: " + topic; - result += "\r\nGroup: " + group; - result += "\r\nKey: " + key; - result += "\r\n\r\nValues (ID - Methode - Standard): "; + result += "\r\nLoad all values: " + loadAll; + result += "\r\n\r\nValues (Group - ID - Key - Keyvalue - Standard): "; int z = 0; foreach (var item in values) { - if (z == 3) + if (z == 5) { z = 0; } + if (z == 4) + { + result += " - " + item; + z++; + } + if (z == 3) + { + result += " - " + item; + z++; + } if (z == 2) { result += " - " + item; @@ -186,6 +214,48 @@ namespace Test_LoadXMLFile return result; } + private string Ausgabe1(string fileName, string topic, string group, string key, string[,] values) + { + string result = ""; + + result = "Filename: " + fileName; + result += "\r\nTopic: " + topic; + result += "\r\n\r\nGroup: " + group; + result += "\r\nKey: " + key; + result += "\r\n\r\nValues (ID - Management - Standard): "; + + int z = 0; + + foreach (var item in values) + { + if (z == 4) + { + z = 0; + } + if (z == 3) + { + result += " - " + item; + z++; + } + if (z == 2) + { + result += " - " + item; + z++; + } + if (z == 1) + { + result += "\r\n" + item; + z++; + } + if (z == 0) + { + z++; + } + } + + return result; + } + private string Ausgabe2(string group, string key, string[,] values) { string result = ""; @@ -198,10 +268,15 @@ namespace Test_LoadXMLFile foreach (var item in values) { - if (z == 3) + if (z == 4) { z = 0; } + if (z == 3) + { + result += " - " + item; + z++; + } if (z == 2) { result += " - " + item; @@ -209,12 +284,11 @@ namespace Test_LoadXMLFile } if (z == 1) { - result += " - " + item; + result += "\r\n" + item; z++; } if (z == 0) { - result += "\r\n" + item; z++; } } diff --git a/Test_LoadXMLFile/bin/Debug/Test_LoadXMLFile.exe b/Test_LoadXMLFile/bin/Debug/Test_LoadXMLFile.exe index 1898dbd..44c951e 100644 Binary files a/Test_LoadXMLFile/bin/Debug/Test_LoadXMLFile.exe and b/Test_LoadXMLFile/bin/Debug/Test_LoadXMLFile.exe differ diff --git a/Test_LoadXMLFile/bin/Debug/Test_LoadXMLFile.pdb b/Test_LoadXMLFile/bin/Debug/Test_LoadXMLFile.pdb index fa23cab..e94747f 100644 Binary files a/Test_LoadXMLFile/bin/Debug/Test_LoadXMLFile.pdb and b/Test_LoadXMLFile/bin/Debug/Test_LoadXMLFile.pdb differ diff --git a/Test_LoadXMLFile/bin/Debug/heloxmlf.dll b/Test_LoadXMLFile/bin/Debug/heloxmlf.dll index 1c6e17e..0644e58 100644 Binary files a/Test_LoadXMLFile/bin/Debug/heloxmlf.dll and b/Test_LoadXMLFile/bin/Debug/heloxmlf.dll differ diff --git a/Test_LoadXMLFile/bin/Debug/heloxmlf.pdb b/Test_LoadXMLFile/bin/Debug/heloxmlf.pdb index 2e4f4d6..9d0a800 100644 Binary files a/Test_LoadXMLFile/bin/Debug/heloxmlf.pdb and b/Test_LoadXMLFile/bin/Debug/heloxmlf.pdb differ diff --git a/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.csproj.AssemblyReference.cache b/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.csproj.AssemblyReference.cache index 225dcab..0a4629b 100644 Binary files a/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.csproj.AssemblyReference.cache and b/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.csproj.AssemblyReference.cache differ diff --git a/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.csproj.GenerateResource.cache b/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.csproj.GenerateResource.cache index 405151a..a0ffa9a 100644 Binary files a/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.csproj.GenerateResource.cache and b/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.csproj.GenerateResource.cache differ diff --git a/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.exe b/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.exe index 1898dbd..44c951e 100644 Binary files a/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.exe and b/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.exe differ diff --git a/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.pdb b/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.pdb index fa23cab..e94747f 100644 Binary files a/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.pdb and b/Test_LoadXMLFile/obj/Debug/Test_LoadXMLFile.pdb differ