internal Type ResolvePrefixedNameWithAdditionalWpfSemantics(string prefixedName, DependencyObject element) { // First, get the xmlns dictionary off of the provided Tree Element. object dictObject = element.GetValue(System.Windows.Markup.XmlAttributeProperties.XmlnsDictionaryProperty); var prefixDictionary = dictObject as System.Windows.Markup.XmlnsDictionary; object mapsObject = element.GetValue(System.Windows.Markup.XmlAttributeProperties.XmlNamespaceMapsProperty); var namespaceMaps = mapsObject as Hashtable; // If there was no xmlns map on the given Tree Element. // Then, as a last resort, if the prefix was "" use the Wpf Element URI. if (prefixDictionary == null) { if (_wpfDefaultNamespace == null) { var wpfDefaultNamespace = new System.Windows.Markup.XmlnsDictionary(); wpfDefaultNamespace.Add(String.Empty, Baml2006SchemaContext.WpfNamespace); _wpfDefaultNamespace = wpfDefaultNamespace; } prefixDictionary = _wpfDefaultNamespace; } else { if (namespaceMaps != null && namespaceMaps.Count > 0) { // This DO was loaded with a custom XamlTypeMapper. Try the custom mappings first. Type result = System.Windows.Markup.XamlTypeMapper.GetTypeFromName(prefixedName, element); if (result != null) { return(result); } } } XamlTypeName xamlTypeName; if (XamlTypeName.TryParse(prefixedName, prefixDictionary, out xamlTypeName)) { XamlType xamlType = GetXamlType(xamlTypeName); if (xamlType != null) { return(xamlType.UnderlyingType); } } return(null); }
internal Type ResolvePrefixedNameWithAdditionalWpfSemantics(string prefixedName, DependencyObject element) { // First, get the xmlns dictionary off of the provided Tree Element. object dictObject = element.GetValue(System.Windows.Markup.XmlAttributeProperties.XmlnsDictionaryProperty); var prefixDictionary = dictObject as System.Windows.Markup.XmlnsDictionary; object mapsObject = element.GetValue(System.Windows.Markup.XmlAttributeProperties.XmlNamespaceMapsProperty); var namespaceMaps = mapsObject as Hashtable; // If there was no xmlns map on the given Tree Element. // Then, as a last resort, if the prefix was "" use the Wpf Element URI. if (prefixDictionary == null) { if (_wpfDefaultNamespace == null) { var wpfDefaultNamespace = new System.Windows.Markup.XmlnsDictionary(); wpfDefaultNamespace.Add(String.Empty, Baml2006SchemaContext.WpfNamespace); _wpfDefaultNamespace = wpfDefaultNamespace; } prefixDictionary = _wpfDefaultNamespace; } else { if (namespaceMaps != null && namespaceMaps.Count > 0) { // This DO was loaded with a custom XamlTypeMapper. Try the custom mappings first. Type result = System.Windows.Markup.XamlTypeMapper.GetTypeFromName(prefixedName, element); if (result != null) { return result; } } } XamlTypeName xamlTypeName; if (XamlTypeName.TryParse(prefixedName, prefixDictionary, out xamlTypeName)) { XamlType xamlType = GetXamlType(xamlTypeName); if (xamlType != null) { return xamlType.UnderlyingType; } } return null; }
public XmlnsDictionary(System.Windows.Markup.XmlnsDictionary xmlnsDictionary) { Contract.Ensures(0 <= xmlnsDictionary.Count); }