本文整理汇总了C#中System.Runtime.Serialization.DataContractResolver.TryResolveType方法的典型用法代码示例。如果您正苦于以下问题:C# DataContractResolver.TryResolveType方法的具体用法?C# DataContractResolver.TryResolveType怎么用?C# DataContractResolver.TryResolveType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.Serialization.DataContractResolver
的用法示例。
在下文中一共展示了DataContractResolver.TryResolveType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryResolveType
// Used at serialization
// Maps any Type to a new xsi:type representation
public override bool TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, out XmlDictionaryString typeName, out XmlDictionaryString typeNamespace)
{
string name = type.Name;
string namesp = type.Namespace;
typeName = new XmlDictionaryString(XmlDictionary.Empty, name, 0);
typeNamespace = new XmlDictionaryString(XmlDictionary.Empty, namesp, 0);
if (!dictionary.ContainsKey(type.Name))
{
dictionary.Add(name, typeName);
}
if (!dictionary.ContainsKey(type.Namespace))
{
dictionary.Add(namesp, typeNamespace);
}
return true;
}