本文整理汇总了C#中System.Xml.Serialization.XmlAttributeOverrides.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# XmlAttributeOverrides.GetHashCode方法的具体用法?C# XmlAttributeOverrides.GetHashCode怎么用?C# XmlAttributeOverrides.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Serialization.XmlAttributeOverrides
的用法示例。
在下文中一共展示了XmlAttributeOverrides.GetHashCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSerializer
/// <summary>
/// Create or reuse a XmlSerializer with a specific override!
/// The .NET Factory method "CreateSerializer" do not support caching with a custom override!
/// This method is optimized for speed and is threadsafe.
/// </summary>
/// <param name="factory"></param>
/// <param name="type"></param>
/// <param name="overrides"></param>
/// <returns></returns>
public static XmlSerializer GetSerializer(this XmlSerializerFactory factory, Type type, XmlAttributeOverrides overrides)
{
XmlSerializer result = null;
string key = type.AssemblyQualifiedName;
if (overrides != null)
{
key += overrides.GetHashCode();
if (!serializerTable.TryGetValue(key, out result))
{
result = factory.CreateSerializer(type, overrides);
serializerTable.MergeSafe(key, result);
}
}
else
{
result = factory.CreateSerializer(type);
}
return result;
}