/// <summary> /// Creates a signature for the passed in XmlAttributeOverrides /// </summary> /// <param name="overrides"></param> /// <returns>An instance indpendent signature of the XmlAttributeOverrides</returns> public static string GetOverridesSignature(XmlAttributeOverrides overrides) { // GetHashCode looks at something other than the content // of XmlOverrideAttributes and comes up with different // hash values for two instances that would produce // the same XML is the were applied to the XmlSerializer. // Therefore I need to do something more intelligent // to normalize the content of XmlAttributeOverrides // or extract a thumbpront that only accounts for the // attributes in XmlAttributeOverrides. // The main problems is that // I can only access the hashtables that store the // overriding attributes through reflection, i.e. // I can't run the XmlSerializerCache in a partially // trusted security context. // // Also, the extra computation to create a purely // content-based thumbprint not offset the savings. // // If none if these were an issue I'd simply say: // return overrides.GetHashCode().ToString(); return(null == overrides ? null : XmlAttributeOverridesThumbprinter.GetThumbprint(overrides)); }
/// <summary> /// Creates a signature for the passed in XmlRootAttribute /// </summary> /// <param name="root"></param> /// <returns>An instance indpendent signature of the XmlRootAttribute</returns> public static string GetXmlRootSignature(XmlRootAttribute root) { StringBuilder sb = new StringBuilder(); XmlAttributeOverridesThumbprinter.AddXmlRootPrint(root, sb); return(sb.ToString()); }