Beispiel #1
0
 public void AddNamespace(XmlnsPrefix prefix, IXmlNamespace xmlNamespace)
 {
     if (this.namespaces == null)
     {
         this.namespaces = new XmlNamespaceMap();
     }
     this.namespaces.AddNamespace(prefix, xmlNamespace);
 }
 public XmlNamespace GetXmlNamespace(XmlnsPrefix prefix, XmlNamespaceCanonicalization canonicalization)
 {
     if (prefix == XmlnsPrefix.EmptyPrefix)
     {
         return(XmlNamespace.AvalonXmlNamespace);
     }
     if (prefix.Value == "x")
     {
         return(XmlNamespace.XamlXmlNamespace);
     }
     return((XmlNamespace)null);
 }
 XmlNamespace IXmlNamespaceResolver.GetXmlNamespace(XmlnsPrefix prefix, XmlNamespaceCanonicalization canonicalization)
 {
     for (XmlElementReference elementReference = this; elementReference != null; elementReference = elementReference.Parent as XmlElementReference)
     {
         foreach (XmlElementReference.Attribute attribute in elementReference.AttributesToPreserve)
         {
             if ((attribute.Type == XmlElementReference.AttributeType.Xmlns || attribute.Type == XmlElementReference.AttributeType.SerializerAddedXmlns) && string.Equals(string.IsNullOrEmpty(attribute.XmlAttribute.Prefix) ? attribute.XmlAttribute.Prefix : attribute.XmlAttribute.LocalName, prefix.Value, StringComparison.Ordinal))
             {
                 return(XmlNamespace.ToNamespace(attribute.XmlAttribute.Value.Value, canonicalization));
             }
         }
     }
     return((XmlNamespace)null);
 }
Beispiel #4
0
        public XmlnsPrefix GetPrefix(IXmlNamespace xmlNamespace)
        {
            if (this.HasNamespaces)
            {
                XmlnsPrefix prefix = this.namespaces.GetPrefix(xmlNamespace);
                if (prefix != null)
                {
                    return(prefix);
                }
            }
            ElementNode elementNode = this.Parent as ElementNode;

            if (elementNode != null)
            {
                return(elementNode.GetPrefix(xmlNamespace));
            }
            return((XmlnsPrefix)null);
        }
Beispiel #5
0
        public IXmlNamespace GetNamespace(XmlnsPrefix prefix)
        {
            if (this.HasNamespaces)
            {
                IXmlNamespace @namespace = this.namespaces.GetNamespace(prefix);
                if (@namespace != null)
                {
                    return(@namespace);
                }
            }
            ElementNode elementNode = this.Parent as ElementNode;

            if (elementNode != null)
            {
                return(elementNode.GetNamespace(prefix));
            }
            return((IXmlNamespace)null);
        }
Beispiel #6
0
        internal static bool SplitTypeName(XamlParserContext parserContext, ITextLocation lineInformation, string prefixAndTypeName, out XmlnsPrefix prefix, out string typeName)
        {
            int length = prefixAndTypeName.IndexOf(':');

            if (length >= 0)
            {
                if (length == 0 || length == prefixAndTypeName.Length - 1)
                {
                    parserContext.ReportError(XamlParseErrors.InvalidPrefixQualifiedTypeName(lineInformation, prefixAndTypeName));
                    prefix   = (XmlnsPrefix)null;
                    typeName = (string)null;
                    return(false);
                }
                prefix   = XmlnsPrefix.ToPrefix(prefixAndTypeName.Substring(0, length));
                typeName = prefixAndTypeName.Substring(length + 1);
                return(true);
            }
            prefix   = XmlnsPrefix.EmptyPrefix;
            typeName = prefixAndTypeName;
            return(true);
        }
Beispiel #7
0
 public static XamlParseError DuplicateXmlnsPrefix(ITextLocation lineInformation, XmlnsPrefix prefix)
 {
     return(XamlParseErrors.NewParseError(XamlErrorSeverity.Error, XamlErrorCode.DuplicateXmlnsPrefix, lineInformation, StringTable.ParserDuplicateXmlnsPrefix, prefix.Value));
 }
Beispiel #8
0
        public XmlNamespace GetXmlNamespace(ITextLocation lineInformation, IXmlNamespaceResolver xmlNamespaceResolver, XmlnsPrefix prefix)
        {
            XmlNamespace xmlNamespace = xmlNamespaceResolver.GetXmlNamespace(prefix, XmlNamespace.GetNamespaceCanonicalization(this.TypeResolver));

            if (xmlNamespace != null)
            {
                return(xmlNamespace);
            }
            if (prefix == XmlnsPrefix.EmptyPrefix)
            {
                this.ReportError(XamlParseErrors.NoDefaultNamespace(lineInformation));
            }
            else
            {
                this.ReportError(XamlParseErrors.UnrecognizedXmlnsPrefix(lineInformation, prefix));
            }
            return(XmlNamespace.AvalonXmlNamespace);
        }