Esempio n. 1
0
 // 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)
         {
             foreach (var ns in NamespacesInType(xn.Object.Type))
             {
                 PrefixLookup.LookupPrefix(ns);
             }
         }
         else if (xn.NodeType == XamlNodeType.StartMember)
         {
             var xm = xn.Member.Member;
             // This filtering is done as a black list so far. There does not seem to be any usable property on XamlDirective.
             if (xm == XamlLanguage.Items || xm == XamlLanguage.PositionalParameters || xm == XamlLanguage.Initialization)
             {
                 continue;
             }
             PrefixLookup.LookupPrefix(xn.Member.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.
                 TypeExtensionMethods.GetStringValue(XamlLanguage.Type, xn.Member.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);
 }