Ejemplo n.º 1
0
        /// <summary>
        /// override for handling a new xmlnamespace Uri
        /// </summary>
        public override void WriteNamespacePrefix(XamlXmlnsPropertyNode xamlXmlnsPropertyNode)
        {
            if (!_pass2)
            {
                List <ClrNamespaceAssemblyPair> cnap = XamlTypeMapper.GetClrNamespacePairFromCache(xamlXmlnsPropertyNode.XmlNamespace);
                if (cnap != null)
                {
                    foreach (ClrNamespaceAssemblyPair u in cnap)
                    {
                        _compiler.AddUsing(u.ClrNamespace);
                    }
                }
            }

            base.WriteNamespacePrefix(xamlXmlnsPropertyNode);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Write a new namespacePrefix to NamespaceURI map
 /// </summary>
 public virtual void WriteNamespacePrefix(XamlXmlnsPropertyNode xamlXmlnsPropertyNode)
 {
     if (BamlRecordWriter != null)
     {
         BamlRecordWriter.WriteNamespacePrefix(xamlXmlnsPropertyNode);
     }
 }
        /// <summary>
        /// override for handling a new xmlnamespace Uri
        /// </summary>
        public override void WriteNamespacePrefix(XamlXmlnsPropertyNode xamlXmlnsPropertyNode)
        {
            if (!_pass2)
            {
                List<ClrNamespaceAssemblyPair> cnap = XamlTypeMapper.GetClrNamespacePairFromCache(xamlXmlnsPropertyNode.XmlNamespace);
                if (cnap != null)
                {
                    foreach (ClrNamespaceAssemblyPair u in cnap)
                    {
                        _compiler.AddUsing(u.ClrNamespace);
                    }
                }
            }

            base.WriteNamespacePrefix(xamlXmlnsPropertyNode);
        }
        // The current element contains xmlns combinations we want scoped in case
        // InnerXAML is done at runtime.
        internal void WriteNamespacePrefix(XamlXmlnsPropertyNode xamlXmlnsPropertyNode)
        {
            BamlXmlnsPropertyRecord xmlnsRecord =
                (BamlXmlnsPropertyRecord) BamlRecordManager.GetWriteRecord(BamlRecordType.XmlnsProperty);

            xmlnsRecord.Prefix = xamlXmlnsPropertyNode.Prefix;
            xmlnsRecord.XmlNamespace  = xamlXmlnsPropertyNode.XmlNamespace;

#if PBTCOMPILER

            //
            // Get a list of Assemblies that contain XmlnsDefinitionAttribute for the
            // specific XmlNamespace. Add the relevant assemblies into MapTable.
            //

            if (xamlXmlnsPropertyNode.XmlNamespace.StartsWith(XamlReaderHelper.MappingProtocol, StringComparison.Ordinal) == false)
            {
                NamespaceMapEntry[] nsMapEntry = _xamlTypeMapper.GetNamespaceMapEntries(xamlXmlnsPropertyNode.XmlNamespace);

                if (nsMapEntry != null && nsMapEntry.Length > 0)
                {
                    ArrayList asmList = new ArrayList();
                    for (int i = 0; i < nsMapEntry.Length; i++)
                    {
                        string asmName = nsMapEntry[i].AssemblyName;

                        if (!asmList.Contains(asmName))
                        {
                            asmList.Add(asmName);
                        }
                    }

                    if (asmList.Count > 0)
                    {
                        short[] assemblyIds = new short[asmList.Count];

                        for (int i = 0; i < asmList.Count; i++)
                        {
                            BamlAssemblyInfoRecord bamlAssemblyInfoRecord = MapTable.AddAssemblyMap(BinaryWriter, (string)asmList[i]);

                            assemblyIds[i] = bamlAssemblyInfoRecord.AssemblyId;
                        }

                        xmlnsRecord.AssemblyIds = assemblyIds;
                    }
                }
            }

#endif


            // NOTE:  If we are defining a new namespace prefix in the value object's
            //        start record, AND using that prefix in x:Key, then we have a
            //        problem, since the x:Key keys are hoisted out before this
            //        record in the baml stream....  I don't have a solution for
            //        this yet, but this isn't an issue for theme files...
            WriteAndReleaseRecord(xmlnsRecord, xamlXmlnsPropertyNode);
        }