Preventing XML Serialization of IEnumerable and ICollection & Inherited Types?

You can get around this problem by getting hold of the System.RunTime. Serialization dll (it's a . Net 3.

X assembly) and referencing it from your . Net 2.0 application. This works because the .

Net 3.0 binaries are compiled to run on the . Net 2.0 CLR By doing this, you get access to the DataContractSerliazer which I've used to get around a similar problem where I wanted to pass in a ICollection as a parameter to a webservice and the xmlserializer didn't know how to deal with it properly If you're cool with using the . Net 3.

X dll in your 2. X application you should be able to use the DataContractSerializer to solve this problem.

You can get around this problem by getting hold of the System.RunTime. Serialization dll (it's a . Net 3.

X assembly) and referencing it from your . Net 2.0 application. This works because the .

Net 3.0 binaries are compiled to run on the . Net 2.0 CLR. By doing this, you get access to the DataContractSerliazer which I've used to get around a similar problem where I wanted to pass in a ICollection as a parameter to a webservice and the xmlserializer didn't know how to deal with it properly.

If you're cool with using the . Net 3. X dll in your 2.

X application you should be able to use the DataContractSerializer to solve this problem.

I guess the answer is coming too late to be useful for your particular application, but maybe there are other people having the same problem. I suppose you can implement IXmlSerializable for the IEnumerable type to work around this behaviour. However, this means you have to fully control the serialization process for this type.

A simple approach for not having to mess with the XmlReader / XmlWriter, you can write a helper xml adapter class with public ctor and public read-write-properties of all the data to be serialized, and create a temporary XmlSerializer object for this type inside IXmlSerializable. Read|WriteXml(). Class Target : IEnumerable, IXmlSerializable { //... public void ReadXml(System.Xml.

XmlReader reader) { reader. ReadStartElement(); TargetXmlAdapter toRead = (TargetXmlAdapter)new XmlSerializer(typeof(TargetXmlAdapter)). Deserialize(reader); reader.Read(); // here: install state from TargetXmlAdapter } public void WriteXml(System.Xml.

XmlWriter writer) { // NOTE: TargetXmlAdapter(Target) is supposed to store this' state being subject to serialization new XmlSerializer(typeof(TargetXmlAdapter)). Serialize(writer, new TargetXmlAdapter(this)); } }.

If you use these attributes: XmlArray("ProviderPatientLists") XmlArrayItem("File") public ProviderPatientList Files { get { return _ProviderPatientLists; } set { _ProviderPatientLists = value; } } Where ProviderPatientList inherit's List You can then have more control over the xml outputed will create.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions