internal void TryAddAliasedProperty(XamlDirective directive, XamlMember member) { Debug.Assert(!IsUnknown); if (directive == XamlLanguage.Key) { _dictionaryKeyProperty.Value = member; } else if (directive == XamlLanguage.Name) { _runtimeNameProperty.Value = member; } else if (directive == XamlLanguage.Uid) { _uidProperty.Value = member; } else if (directive == XamlLanguage.Lang) { _xmlLangProperty.Value = member; } else { if (_aliasedProperties == null) { var dict = XamlSchemaContext.CreateDictionary <XamlDirective, XamlMember>(); Interlocked.CompareExchange(ref _aliasedProperties, dict, null); } _aliasedProperties.TryAdd(directive, member); } }
private ConcurrentDictionary <string, IList <string> > LoadClrToXmlNs() { ConcurrentDictionary <string, IList <string> > dict = XamlSchemaContext.CreateDictionary <string, IList <string> >(); System.Reflection.Assembly assembly = this.Assembly; if (assembly != null) { foreach (XmlNsDefinition definition in this.NsDefs) { IList <string> list; if (!dict.TryGetValue(definition.ClrNamespace, out list)) { list = new List <string>(); dict.TryAdd(definition.ClrNamespace, list); } list.Add(definition.XmlNamespace); } string assemblyName = this._fullyQualifyAssemblyName ? assembly.FullName : XamlSchemaContext.GetAssemblyShortName(assembly); foreach (KeyValuePair <string, IList <string> > pair in dict) { List <string> list2 = (List <string>)pair.Value; NamespaceComparer comparer = new NamespaceComparer(this, assembly); list2.Sort(new Comparison <string>(comparer.CompareNamespacesByPreference)); string uri = ClrNamespaceUriParser.GetUri(pair.Key, assemblyName); list2.Add(uri); } this.MakeListsImmutable(dict); } return(dict); }
internal void TryAddAliasedProperty(XamlDirective directive, XamlMember member) { if (directive == XamlLanguage.Key) { this._dictionaryKeyProperty.Value = member; } else if (directive == XamlLanguage.Name) { this._runtimeNameProperty.Value = member; } else if (directive == XamlLanguage.Uid) { this._uidProperty.Value = member; } else if (directive == XamlLanguage.Lang) { this._xmlLangProperty.Value = member; } else { if (this._aliasedProperties == null) { ConcurrentDictionary <XamlDirective, XamlMember> dictionary = XamlSchemaContext.CreateDictionary <XamlDirective, XamlMember>(); Interlocked.CompareExchange <ConcurrentDictionary <XamlDirective, XamlMember> >(ref this._aliasedProperties, dictionary, null); } this._aliasedProperties.TryAdd(directive, member); } }
ConcurrentDictionary <string, IList <string> > LoadClrToXmlNs() { ConcurrentDictionary <string, IList <string> > result = XamlSchemaContext.CreateDictionary <string, IList <string> >(); Assembly assembly = Assembly; if (assembly == null) { return(result); } foreach (XmlNsDefinition nsDef in NsDefs) { IList <string> xmlNamespaceList; if (!result.TryGetValue(nsDef.ClrNamespace, out xmlNamespaceList)) { xmlNamespaceList = new List <string>(); result.TryAdd(nsDef.ClrNamespace, xmlNamespaceList); } xmlNamespaceList.Add(nsDef.XmlNamespace); } string assemblyName = _fullyQualifyAssemblyName ? assembly.FullName : XamlSchemaContext.GetAssemblyShortName(assembly); foreach (KeyValuePair <string, IList <string> > clrToXmlNs in result) { // Sort namespaces in preference order List <string> nsList = (List <string>)clrToXmlNs.Value; NamespaceComparer comparer = new NamespaceComparer(this, assembly); nsList.Sort(comparer.CompareNamespacesByPreference); // Add clr-namespace form as last choice string clrNsUri = ClrNamespaceUriParser.GetUri(clrToXmlNs.Key, assemblyName); nsList.Add(clrNsUri); } // Convert to read-only lists so we can safely return these from public API MakeListsImmutable(result); return(result); }
private void Initialize() { _typeCache = XamlSchemaContext.CreateDictionary <string, XamlType>(); }