本文整理汇总了C#中System.Runtime.Serialization.IExtensibleDataObject接口的典型用法代码示例。如果您正苦于以下问题:C# IExtensibleDataObject接口的具体用法?C# IExtensibleDataObject怎么用?C# IExtensibleDataObject使用的例子?那么恭喜您, 这里精选的接口代码示例或许可以为您提供帮助。
IExtensibleDataObject接口属于System.Runtime.Serialization命名空间,在下文中一共展示了IExtensibleDataObject接口的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1:
// Implement the IExtensibleDataObject interface
// to store the extra data for future versions.
[DataContract(
Name = "Person",
Namespace = "http://www.cohowinery.com/employees")]
class Person : IExtensibleDataObject
{
// To implement the IExtensibleDataObject interface,
// you must implement the ExtensionData property. The property
// holds data from future versions of the class for backward
// compatibility.
private ExtensionDataObject extensionDataObject_value;
public ExtensionDataObject ExtensionData
{
get
{
return extensionDataObject_value;
}
set
{
extensionDataObject_value = value;
}
}
[DataMember]
public string Name;
}
// The second version of the class adds a new field. The field's
// data is stored in the ExtensionDataObject field of
// the first version (Person). You must also set the Name property
// of the DataContractAttribute to match the first version.
// If necessary, also set the Namespace property so that the
// name of the contracts is the same.
[DataContract(Name = "Person",
Namespace = "http://www.cohowinery.com/employees")]
class PersonVersion2 : IExtensibleDataObject
{
// Best practice: add an Order number to new members.
[DataMember(Order=2)]
public int ID;
[DataMember]
public string Name;
private ExtensionDataObject extensionDataObject_value;
public ExtensionDataObject ExtensionData
{
get
{
return extensionDataObject_value;
}
set
{
extensionDataObject_value = value;
}
}
}
开发者ID:.NET开发者,项目名称:System.Runtime.Serialization,代码行数:57,代码来源:IExtensibleDataObject
注:本文中的System.Runtime.Serialization.IExtensibleDataObject接口示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论