Hallo zusammen,
Ich bin grad am Verzweifeln. Ich habe eine Klasse die sieht so aus:
[highlight=c#]
[Serializable]
public class FmeaIdentifier:ISerializable
{
private readonly String _partStart;
private readonly List<String> _fmeaMatchingErrors;
private readonly String _tcaIdentifier;
public FmeaIdentifier(string partStart, List<string> fmeaMatchingErrors, string tcaIdentifier)
{
_partStart = partStart;
_tcaIdentifier = tcaIdentifier;
_fmeaMatchingErrors = fmeaMatchingErrors;
}
protected FmeaIdentifier(SerializationInfo info, StreamingContext context)
{
_partStart = info.GetString("PartStart");
_fmeaMatchingErrors = (List<String>) info.GetValue("FmeaMatchingErrors", typeof (List<String>));
_tcaIdentifier = info.GetString("TcaIdentifier");
}
protected FmeaIdentifier()
{
}
public string TcaIdentifier { get { return _tcaIdentifier; } }
public IList<string> FmeaMatchingErrors { get { return _fmeaMatchingErrors; } }
public string PartStart { get { return _partStart; } }
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("PartStart",_partStart);
info.AddValue("TcaIdentifier",_tcaIdentifier);
info.AddValue("FmeaMatchingErrors",_fmeaMatchingEr rors);
}
}
[/highlight]
Anlegen tue ich die Teile so:
[highlight=c#]
_identifiers = new List<FmeaIdentifier>();
_identifiers.Add(new FmeaIdentifier("R", new List<string> { "open", "hello world" }, "open"));
_identifiers.Add(new FmeaIdentifier("C", new List<string> { "open" }, "open"));
[/highlight]
Nun serialisiere ich diese mit:
[highlight=c#]
var fs = new StreamWriter(filePath, false);
var serializer = new XmlSerializer(typeof(List<FmeaIdentifier>));
serializer.Serialize(fs, _identifiers);
fs.Close();
[/highlight]
Nun hab ich aber das Problem das in meinem File nur leere Elemente auftauchen. GetObjectData() wird aufgerufen. Das habe ich schon überprüft.
Hat jemand einen Tip für mich? Ich möchte die Felder nicht public machen.
Hoffe jemand kann helfen!
Vielen Dank schon mal!!!
Gruß
Fanderlf
Ich bin grad am Verzweifeln. Ich habe eine Klasse die sieht so aus:
[highlight=c#]
[Serializable]
public class FmeaIdentifier:ISerializable
{
private readonly String _partStart;
private readonly List<String> _fmeaMatchingErrors;
private readonly String _tcaIdentifier;
public FmeaIdentifier(string partStart, List<string> fmeaMatchingErrors, string tcaIdentifier)
{
_partStart = partStart;
_tcaIdentifier = tcaIdentifier;
_fmeaMatchingErrors = fmeaMatchingErrors;
}
protected FmeaIdentifier(SerializationInfo info, StreamingContext context)
{
_partStart = info.GetString("PartStart");
_fmeaMatchingErrors = (List<String>) info.GetValue("FmeaMatchingErrors", typeof (List<String>));
_tcaIdentifier = info.GetString("TcaIdentifier");
}
protected FmeaIdentifier()
{
}
public string TcaIdentifier { get { return _tcaIdentifier; } }
public IList<string> FmeaMatchingErrors { get { return _fmeaMatchingErrors; } }
public string PartStart { get { return _partStart; } }
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("PartStart",_partStart);
info.AddValue("TcaIdentifier",_tcaIdentifier);
info.AddValue("FmeaMatchingErrors",_fmeaMatchingEr rors);
}
}
[/highlight]
Anlegen tue ich die Teile so:
[highlight=c#]
_identifiers = new List<FmeaIdentifier>();
_identifiers.Add(new FmeaIdentifier("R", new List<string> { "open", "hello world" }, "open"));
_identifiers.Add(new FmeaIdentifier("C", new List<string> { "open" }, "open"));
[/highlight]
Nun serialisiere ich diese mit:
[highlight=c#]
var fs = new StreamWriter(filePath, false);
var serializer = new XmlSerializer(typeof(List<FmeaIdentifier>));
serializer.Serialize(fs, _identifiers);
fs.Close();
[/highlight]
Nun hab ich aber das Problem das in meinem File nur leere Elemente auftauchen. GetObjectData() wird aufgerufen. Das habe ich schon überprüft.
Hat jemand einen Tip für mich? Ich möchte die Felder nicht public machen.
Hoffe jemand kann helfen!
Vielen Dank schon mal!!!
Gruß
Fanderlf
Comment