Basically, should the code below work and serialize string Yoyo
when an object of type YoyoData
is returned over the wire.
public interface IHelloV1
{
#region Instance Properties
[DataMember(Name = "Yoyo")]
string Yoyo { get; set; }
#endregion
}
[DataContract(Name = "YoyoData", Namespace = "http://hello.com/1/IHelloV1")]
public class YoyoData : IHelloV1
{
string Yoyo { get; set; }
public YoyoData()
{
Yoyo = "whatever";
}
}
}
I don't think it will.
The DataMember
attribute is not inherited in derived classes.
For more details see documentation of type DataMemberAttribute
and how it is defined : http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datamemberattribute.aspx.
This attribute specifies the property Inherited = false
meaning the attribute won't be propagated to derived classes.
Also see http://msdn.microsoft.com/en-us/library/84c42s56(v=vs.71).aspx for more details concerning the Inherited
property on attributes.
Anyway, this means that in your class defining the DataContract
, the property Yoyo
won't be considered a DataMember
so for me it will just not work as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With