private void EnqueueAnotherAttribute(bool isEmptyTag)
        {
            XamlAttribute attr = this._attributes[this._nextAttribute++];
            XamlScannerNode item = new XamlScannerNode(attr);
            switch (attr.Kind)
            {
                case ScannerAttributeKind.CtorDirective:
                case ScannerAttributeKind.Name:
                case ScannerAttributeKind.Directive:
                    item.NodeType = ScannerNodeType.DIRECTIVE;
                    goto Label_00F3;

                case ScannerAttributeKind.XmlSpace:
                    if (!isEmptyTag)
                    {
                        if (!KS.Eq(attr.Value, "preserve"))
                        {
                            this._scannerStack.CurrentXmlSpacePreserve = false;
                            break;
                        }
                        this._scannerStack.CurrentXmlSpacePreserve = true;
                    }
                    break;

                case ScannerAttributeKind.Event:
                case ScannerAttributeKind.Property:
                    item.IsCtorForcingMember = true;
                    item.NodeType = ScannerNodeType.ATTRIBUTE;
                    goto Label_00F3;

                case ScannerAttributeKind.AttachableProperty:
                    item.NodeType = ScannerNodeType.ATTRIBUTE;
                    goto Label_00F3;

                case ScannerAttributeKind.Unknown:
                {
                    XamlMember property = attr.Property;
                    item.IsCtorForcingMember = !property.IsAttachable && !property.IsDirective;
                    item.NodeType = ScannerNodeType.ATTRIBUTE;
                    goto Label_00F3;
                }
                default:
                    throw new XamlInternalException(System.Xaml.SR.Get("AttributeUnhandledKind"));
            }
            item.NodeType = ScannerNodeType.DIRECTIVE;
        Label_00F3:
            item.PropertyAttribute = attr.Property;
            XamlText text = new XamlText(true);
            text.Paste(attr.Value, false);
            item.PropertyAttributeText = text;
            item.Prefix = attr.Name.Prefix;
            this._readNodesQueue.Enqueue(item);
            if (this._nextAttribute >= this._attributes.Count)
            {
                this._attributes = null;
                this._nextAttribute = -1;
            }
        }
 private void ReadPropertyElement(XamlPropertyName name, XamlType tagType, string tagNamespace, bool isEmptyTag)
 {
     XamlScannerNode node = new XamlScannerNode(this._xmlLineInfo);
     this.PreprocessAttributes();
     string namespaceURI = this._xmlReader.NamespaceURI;
     XamlMember member = null;
     bool tagIsRoot = this._scannerStack.Depth == 1;
     member = this._parserContext.GetDottedProperty(tagType, tagNamespace, name, tagIsRoot);
     node.Prefix = name.Prefix;
     node.TypeNamespace = namespaceURI;
     node.IsEmptyTag = isEmptyTag;
     this.PostprocessAttributes(node);
     if (this._scannerStack.Depth > 0)
     {
         this._scannerStack.CurrentlyInContent = false;
     }
     node.PropertyElement = member;
     node.IsCtorForcingMember = !member.IsAttachable;
     if (!node.IsEmptyTag)
     {
         this._scannerStack.CurrentProperty = node.PropertyElement;
         node.NodeType = ScannerNodeType.PROPERTYELEMENT;
     }
     else
     {
         node.NodeType = ScannerNodeType.EMPTYPROPERTYELEMENT;
     }
     this._readNodesQueue.Enqueue(node);
     while (this.HaveUnprocessedAttributes)
     {
         this.EnqueueAnotherAttribute(isEmptyTag);
     }
 }
 private void ReadObjectElement_NoNamespace(XamlName name, XamlScannerNode node)
 {
     XamlType type = this.CreateErrorXamlType(name, string.Empty);
     node.Type = type;
     this.PostprocessAttributes(node);
     if (!node.IsEmptyTag)
     {
         node.NodeType = ScannerNodeType.ELEMENT;
         this._scannerStack.Push(node.Type, node.TypeNamespace);
     }
     else
     {
         node.NodeType = ScannerNodeType.EMPTYELEMENT;
     }
 }
 private bool ReadObjectElement_Object(string xmlns, string name, XamlScannerNode node)
 {
     if (this.IsXDataElement(xmlns, name))
     {
         this.ReadInnerXDataSection();
         return true;
     }
     IList<XamlTypeName> typeArguments = null;
     if (this._typeArgumentAttribute != null)
     {
         string str;
         typeArguments = XamlTypeName.ParseListInternal(this._typeArgumentAttribute.Value, new Func<string, string>(this._parserContext.FindNamespaceByPrefix), out str);
         if (typeArguments == null)
         {
             throw new XamlParseException(this._typeArgumentAttribute.LineNumber, this._typeArgumentAttribute.LinePosition, str);
         }
     }
     XamlTypeName typeName = new XamlTypeName(xmlns, name, typeArguments);
     node.Type = this._parserContext.GetXamlType(typeName, true);
     this.PostprocessAttributes(node);
     if (this._scannerStack.Depth > 0)
     {
         this._scannerStack.CurrentlyInContent = true;
     }
     if (!node.IsEmptyTag)
     {
         node.NodeType = ScannerNodeType.ELEMENT;
         this._scannerStack.Push(node.Type, node.TypeNamespace);
     }
     else
     {
         node.NodeType = ScannerNodeType.EMPTYELEMENT;
     }
     return false;
 }
 private void ReadObjectElement(XamlName name, bool isEmptyTag)
 {
     this._typeArgumentAttribute = null;
     XamlScannerNode node = new XamlScannerNode(this._xmlLineInfo);
     this.PreprocessAttributes();
     node.Prefix = name.Prefix;
     node.IsEmptyTag = isEmptyTag;
     string namespaceURI = this._xmlReader.NamespaceURI;
     if (namespaceURI == null)
     {
         this.ReadObjectElement_NoNamespace(name, node);
     }
     else
     {
         node.TypeNamespace = namespaceURI;
         XamlMember xamlDirective = this._parserContext.SchemaContext.GetXamlDirective(namespaceURI, name.Name);
         if (xamlDirective != null)
         {
             this.ReadObjectElement_DirectiveProperty(xamlDirective, node);
         }
         else if (this.ReadObjectElement_Object(namespaceURI, name.Name, node))
         {
             return;
         }
     }
     this._readNodesQueue.Enqueue(node);
     while (this.HaveUnprocessedAttributes)
     {
         this.EnqueueAnotherAttribute(isEmptyTag);
     }
 }
 private void ReadObjectElement_DirectiveProperty(XamlMember dirProperty, XamlScannerNode node)
 {
     node.PropertyElement = dirProperty;
     this.PostprocessAttributes(node);
     if (this._scannerStack.Depth > 0)
     {
         this._scannerStack.CurrentlyInContent = false;
     }
     if (!node.IsEmptyTag)
     {
         this._scannerStack.CurrentProperty = node.PropertyElement;
     }
     node.NodeType = ScannerNodeType.PROPERTYELEMENT;
     node.IsCtorForcingMember = false;
 }
 private void ReadInnerXDataSection()
 {
     XamlScannerNode item = new XamlScannerNode(this._xmlLineInfo);
     this._xmlReader.MoveToContent();
     string str = this._xmlReader.ReadInnerXml().Trim();
     item.NodeType = ScannerNodeType.TEXT;
     item.IsTextXML = true;
     XamlText text = new XamlText(true);
     text.Paste(str, false);
     item.TextContent = text;
     this._readNodesQueue.Enqueue(item);
     this.ProcessCurrentXmlNode();
 }
 private void ReadNone()
 {
     XamlScannerNode item = new XamlScannerNode(this._xmlLineInfo) {
         NodeType = ScannerNodeType.NONE
     };
     this._readNodesQueue.Enqueue(item);
 }
 private void ReadEndElement()
 {
     this.EnqueueAnyText();
     if (this._scannerStack.CurrentProperty != null)
     {
         this._scannerStack.CurrentProperty = null;
         this._scannerStack.CurrentlyInContent = false;
     }
     else
     {
         this._scannerStack.Pop();
     }
     XamlScannerNode item = new XamlScannerNode(this._xmlLineInfo) {
         NodeType = ScannerNodeType.ENDTAG
     };
     this._readNodesQueue.Enqueue(item);
 }
 public void Read()
 {
     this.LoadQueue();
     this._currentNode = this._readNodesQueue.Dequeue();
 }
        private void PostprocessAttributes(XamlScannerNode node)
        {
            if (this._attributes != null)
            {
                this._nextAttribute = 0;
                if (node.Type == null)
                {
                    if (this._settings.IgnoreUidsOnPropertyElements)
                    {
                        this.StripUidProperty();
                    }
                }
                else
                {
                    bool tagIsRoot = this._scannerStack.Depth == 0;
                    foreach (XamlAttribute attribute in this._attributes)
                    {
                        attribute.Initialize(this._parserContext, node.Type, node.TypeNamespace, tagIsRoot);
                    }
                    List<XamlAttribute> collection = null;
                    List<XamlAttribute> list2 = null;
                    List<XamlAttribute> list3 = null;
                    XamlAttribute item = null;
                    foreach (XamlAttribute attribute3 in this._attributes)
                    {
                        switch (attribute3.Kind)
                        {
                            case ScannerAttributeKind.CtorDirective:
                                if (collection == null)
                                {
                                    collection = new List<XamlAttribute>();
                                }
                                collection.Add(attribute3);
                                break;

                            case ScannerAttributeKind.Name:
                                item = attribute3;
                                break;

                            case ScannerAttributeKind.Directive:
                            case ScannerAttributeKind.XmlSpace:
                                if (attribute3.Property == XamlLanguage.Key)
                                {
                                    this._hasKeyAttribute = true;
                                }
                                if (list2 == null)
                                {
                                    list2 = new List<XamlAttribute>();
                                }
                                list2.Add(attribute3);
                                break;

                            default:
                                if (list3 == null)
                                {
                                    list3 = new List<XamlAttribute>();
                                }
                                list3.Add(attribute3);
                                break;
                        }
                    }
                    this._attributes = new List<XamlAttribute>();
                    if (collection != null)
                    {
                        this._attributes.AddRange(collection);
                    }
                    if (list2 != null)
                    {
                        this._attributes.AddRange(list2);
                    }
                    if (item != null)
                    {
                        this._attributes.Add(item);
                    }
                    if (list3 != null)
                    {
                        this._attributes.AddRange(list3);
                    }
                }
            }
        }
 private void EnqueueTextNode()
 {
     if ((this._scannerStack.Depth != 0) || !this.AccumulatedText.IsWhiteSpaceOnly)
     {
         XamlScannerNode item = new XamlScannerNode(this._xmlLineInfo) {
             NodeType = ScannerNodeType.TEXT,
             TextContent = this.AccumulatedText
         };
         this._readNodesQueue.Enqueue(item);
     }
 }
 private void EnqueuePrefixDefinition(XamlAttribute attr)
 {
     string xmlNsPrefixDefined = attr.XmlNsPrefixDefined;
     string xmlNsUriDefined = attr.XmlNsUriDefined;
     this._parserContext.AddNamespacePrefix(xmlNsPrefixDefined, xmlNsUriDefined);
     XamlScannerNode item = new XamlScannerNode(attr) {
         NodeType = ScannerNodeType.PREFIXDEFINITION,
         Prefix = xmlNsPrefixDefined,
         TypeNamespace = xmlNsUriDefined
     };
     this._readNodesQueue.Enqueue(item);
 }