I have a class:
[DataContract]
public class Result
{
[DataMember] public String Log {get; set;}
[DataMember] public String Data {get; set;}
}
I send this class via WCF and it works fine. But I want to save this class to a xml file after receiving. I try to write:
var serializer = new DataContractSerializer(typeof (T),null,int.MaxValue,
false,true,null,new SharedTypeXmlResolver());
var settings = new XmlWriterSettings { Indent = true };
using (var backing = new StringWriter(CultureInfo.InvariantCulture))
{
using (var writer = XmlWriter.Create(backing, settings))
{
serializer.WriteObject(writer, result);
}
return backing.ToString();
}
But I want to save "Log" property to an XML file and don't want to save "Data" property. How I do this?
XmlIgnore does not work with DataContract serialization. This contract is opt-in, as opposed to Serializable being opt-out.