Hallo,
Ich habe folgenden Code zum Speichern eines objektes:
C#-Quelltext
1: 2: 3: 4: 5: 6:
| SpeicherKlasse Speicherdatei = new SpeicherKlasse(Karte, Ampelliste); XmlSerializer ser = new XmlSerializer(typeof(SpeicherKlasse), new Type[]{typeof(Feld), typeof(Ampeln)}); TextWriter tw = new StreamWriter(sfd.FileName); ser.Serialize(tw, Speicherdatei); tw.Dispose(); tw.Close(); |
Speicherklasse besteht aus Feldern und Ampeln. Diese wiederrum bestehen aus (Array)Double, Integer, Strings, Booleans und (List/Array) Points. Die Datei, die ich abspeichere sieht so aus:
<SpeicherKlasse/>
In Speicherdatei steht allerdings eine ganze Menge drin:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35:
| - Speicherdatei {WindowsFormsApplication1.SpeicherKlasse} WindowsFormsApplication1.SpeicherKlasse - Ampel Count = 4 System.Collections.Generic.List<WindowsFormsApplication1.Ampeln> - [0] {WindowsFormsApplication1.Ampeln} WindowsFormsApplication1.Ampeln - Ampelposition {X = 81 Y = 63} System.Drawing.Point IsEmpty false bool X 81 int Y 63 int + Statische Member System.Drawing.Point System.Drawing.Point + Nicht öffentliche Member - Haltelinie Count = 2 System.Collections.Generic.List<System.Drawing.Point> + [0] {X = 95 Y = 83} System.Drawing.Point + [1] {X = 95 Y = 83} System.Drawing.Point + Rohdatenansicht Herkunft 0 int Name "0" string + [1] {WindowsFormsApplication1.Ampeln} WindowsFormsApplication1.Ampeln + [2] {WindowsFormsApplication1.Ampeln} WindowsFormsApplication1.Ampeln + [3] {WindowsFormsApplication1.Ampeln} WindowsFormsApplication1.Ampeln + Rohdatenansicht Count = 4 System.Collections.Generic.List<WindowsFormsApplication1.Ampeln> - Karte {WindowsFormsApplication1.Feld[40000]} WindowsFormsApplication1.Feld[] - [0] {WindowsFormsApplication1.Feld} WindowsFormsApplication1.Feld bAutoVorhanden false bool bLetztesFeld false bool + dAbstand {double[4]} double[] dAutoGeschwindigkeit 0.0 double dkmhlimit 2.0 double iAmpel -1 int iAutoHerkunft 0 int iAutoID 0 int iAutoRichtung 0 int irestgelbzeit 0 int + pAutoPosition {X = 0 Y = 0} System.Drawing.Point + pLetztesFeld {System.Drawing.Point[4]} System.Drawing.Point[] + pNaechstesFeld {System.Drawing.Point[4]} System.Drawing.Point[] + Position {X = 0 Y = 0} System.Drawing.Point |
Das ist nur ein kleiner Ausschnitt, tatsächlich ist das gesehene nur eine Ampel und ein Feld.
Wieso speichert er nun nichts ab und wie bekomme ich ihn dazu es zu tun?
Gruß
Julian