void LookupNamespacesInType(XamlType xt) { PrefixLookup.LookupPrefix(xt.PreferredXamlNamespace); if (xt.TypeArguments != null) { // It is for x:TypeArguments PrefixLookup.LookupPrefix(XamlLanguage.Xaml2006Namespace); foreach (var targ in xt.TypeArguments) { LookupNamespacesInType(targ); } } }
// Namespace and Reference retrieval. // It is iterated before iterating the actual object nodes, // and results are cached for use in XamlObjectReader. public void PrepareReading() { PrefixLookup.IsCollectingNamespaces = true; NameResolver.IsCollectingReferences = true; foreach (var xn in GetNodes()) { if (xn.NodeType == XamlNodeType.GetObject) { continue; // it is out of consideration here. } if (xn.NodeType == XamlNodeType.StartObject) { LookupNamespacesInType(xn.Object.Type); } else if (xn.NodeType == XamlNodeType.StartMember) { var xm = xn.Member; // This filtering is done as a black list so far. There does not seem to be any usable property on XamlDirective. if (ReferenceEquals(xm, XamlLanguage.Items) || ReferenceEquals(xm, XamlLanguage.PositionalParameters) || ReferenceEquals(xm, XamlLanguage.Initialization)) { continue; } PrefixLookup.LookupPrefix(xn.Member.PreferredXamlNamespace); } else { if (xn.NodeType == XamlNodeType.Value && xn.Value is Type) { // this tries to lookup existing prefix, and if there isn't any, then adds a new declaration. LookupType((Type)xn.Value); } //TypeExtensionMethods.GetStringValue (XamlLanguage.Type, xn.Member, xn.Value, value_serializer_ctx); continue; } } PrefixLookup.Namespaces.Sort((nd1, nd2) => String.CompareOrdinal(nd1.Prefix, nd2.Prefix)); PrefixLookup.IsCollectingNamespaces = false; NameResolver.IsCollectingReferences = false; NameResolver.NameScopeInitializationCompleted(this); }