Beispiel #1
0
        // ============= Element Processing ==================================

        private void ReadElement()
        {
            // Accumulated text is enqueued a piece of content before this element
            EnqueueAnyText();
            _hasKeyAttribute = false;
            // Empty Elements are by definition leaf elements and they
            // don't nest.  So we don't need to stack this state.
            bool isEmptyTag = _xmlReader.IsEmptyElement;

            string prefix       = _xmlReader.Prefix;
            string strippedName = _xmlReader.LocalName;

            if (XamlName.ContainsDot(strippedName))
            {
                Debug.Assert(_xmlReader.NodeType == XmlNodeType.Element);
                XamlPropertyName name = XamlPropertyName.Parse(_xmlReader.Name, _xmlReader.NamespaceURI);
                if (_scannerStack.CurrentType == null)
                {
                    throw LineInfo(new XamlParseException(SR.Get(SRID.ParentlessPropertyElement, _xmlReader.Name)));
                }
                ReadPropertyElement(name, _scannerStack.CurrentType, _scannerStack.CurrentTypeNamespace, isEmptyTag);
            }
            else
            {
                XamlName name = new XamlQualifiedName(prefix, strippedName);
                ReadObjectElement(name, isEmptyTag);
            }
        }
        public static XamlPropertyName Parse(string longName)
        {
            string str;
            string str2;

            if (string.IsNullOrEmpty(longName))
            {
                return(null);
            }
            if (!XamlQualifiedName.Parse(longName, out str, out str2))
            {
                return(null);
            }
            int    startIndex = 0;
            string str3       = string.Empty;
            int    index      = str2.IndexOf('.');

            if (index != -1)
            {
                str3 = str2.Substring(startIndex, index);
                if (string.IsNullOrEmpty(str3))
                {
                    return(null);
                }
                startIndex = index + 1;
            }
            string            str4  = (startIndex == 0) ? str2 : str2.Substring(startIndex);
            XamlQualifiedName owner = null;

            if (!string.IsNullOrEmpty(str3))
            {
                owner = new XamlQualifiedName(str, str3);
            }
            return(new XamlPropertyName(owner, str, str4));
        }
Beispiel #3
0
        public static XamlTypeName ParseIfTrivalName(string text, Func <string, string> prefixResolver, out string error)
        {
            int parenIdx   = text.IndexOf('(');
            int bracketIdx = text.IndexOf('[');

            if (parenIdx != -1 || bracketIdx != -1)
            {
                error = string.Empty;
                return(null);
            }

            string prefix;
            string simpleName;

            error = string.Empty;
            if (!XamlQualifiedName.Parse(text, out prefix, out simpleName))
            {
                error = SR.Get(SRID.InvalidTypeString, text);
                return(null);
            }

            string ns = prefixResolver(prefix);

            if (String.IsNullOrEmpty(ns))
            {
                error = SR.Get(SRID.PrefixNotFound, prefix);
                return(null);
            }
            XamlTypeName xamlTypeName = new XamlTypeName(ns, simpleName);

            return(xamlTypeName);
        }
        public static XamlTypeName ParseIfTrivalName(string text, Func <string, string> prefixResolver, out string error)
        {
            string str;
            string str2;
            int    index = text.IndexOf('(');
            int    num2  = text.IndexOf('[');

            if ((index != -1) || (num2 != -1))
            {
                error = string.Empty;
                return(null);
            }
            error = string.Empty;
            if (!XamlQualifiedName.Parse(text, out str, out str2))
            {
                error = System.Xaml.SR.Get("InvalidTypeString", new object[] { text });
                return(null);
            }
            string str3 = prefixResolver(str);

            if (string.IsNullOrEmpty(str3))
            {
                error = System.Xaml.SR.Get("PrefixNotFound", new object[] { str });
                return(null);
            }
            return(new XamlTypeName(str3, str2));
        }
 public static XamlPropertyName Parse(string longName)
 {
     string str;
     string str2;
     if (string.IsNullOrEmpty(longName))
     {
         return null;
     }
     if (!XamlQualifiedName.Parse(longName, out str, out str2))
     {
         return null;
     }
     int startIndex = 0;
     string str3 = string.Empty;
     int index = str2.IndexOf('.');
     if (index != -1)
     {
         str3 = str2.Substring(startIndex, index);
         if (string.IsNullOrEmpty(str3))
         {
             return null;
         }
         startIndex = index + 1;
     }
     string str4 = (startIndex == 0) ? str2 : str2.Substring(startIndex);
     XamlQualifiedName owner = null;
     if (!string.IsNullOrEmpty(str3))
     {
         owner = new XamlQualifiedName(str, str3);
     }
     return new XamlPropertyName(owner, str, str4);
 }
Beispiel #6
0
        public static XamlPropertyName Parse(string longName)
        {
            if (String.IsNullOrEmpty(longName))
            {
                return(null);
            }

            string prefix;
            string dottedName;

            if (!XamlQualifiedName.Parse(longName, out prefix, out dottedName))
            {
                return(null);
            }

            int    start = 0;
            string owner = string.Empty;

            int dotIdx = dottedName.IndexOf('.');

            if (dotIdx != -1)
            {
                owner = dottedName.Substring(start, dotIdx);

                if (String.IsNullOrEmpty(owner))
                {
                    return(null);
                }

                start = dotIdx + 1;
            }

            string name = (start == 0) ? dottedName : dottedName.Substring(start);

            XamlQualifiedName ownerName = null;

            if (!String.IsNullOrEmpty(owner))
            {
                ownerName = new XamlQualifiedName(prefix, owner);
            }

            XamlPropertyName propName = new XamlPropertyName(ownerName, prefix, name);

            return(propName);
        }
Beispiel #7
0
        private void ReadElement()
        {
            this.EnqueueAnyText();
            this._hasKeyAttribute = false;
            bool   isEmptyElement = this._xmlReader.IsEmptyElement;
            string prefix         = this._xmlReader.Prefix;
            string localName      = this._xmlReader.LocalName;

            if (XamlName.ContainsDot(localName))
            {
                XamlPropertyName name = XamlPropertyName.Parse(this._xmlReader.Name, this._xmlReader.NamespaceURI);
                if (this._scannerStack.CurrentType == null)
                {
                    throw this.LineInfo(new XamlParseException(System.Xaml.SR.Get("ParentlessPropertyElement", new object[] { this._xmlReader.Name })));
                }
                this.ReadPropertyElement(name, this._scannerStack.CurrentType, this._scannerStack.CurrentTypeNamespace, isEmptyElement);
            }
            else
            {
                XamlName name2 = new XamlQualifiedName(prefix, localName);
                this.ReadObjectElement(name2, isEmptyElement);
            }
        }
 private void ReadElement()
 {
     this.EnqueueAnyText();
     this._hasKeyAttribute = false;
     bool isEmptyElement = this._xmlReader.IsEmptyElement;
     string prefix = this._xmlReader.Prefix;
     string localName = this._xmlReader.LocalName;
     if (XamlName.ContainsDot(localName))
     {
         XamlPropertyName name = XamlPropertyName.Parse(this._xmlReader.Name, this._xmlReader.NamespaceURI);
         if (this._scannerStack.CurrentType == null)
         {
             throw this.LineInfo(new XamlParseException(System.Xaml.SR.Get("ParentlessPropertyElement", new object[] { this._xmlReader.Name })));
         }
         this.ReadPropertyElement(name, this._scannerStack.CurrentType, this._scannerStack.CurrentTypeNamespace, isEmptyElement);
     }
     else
     {
         XamlName name2 = new XamlQualifiedName(prefix, localName);
         this.ReadObjectElement(name2, isEmptyElement);
     }
 }