Exemple #1
0
        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();
        }
Exemple #2
0
        private void ReadInnerXDataSection()
        {
            XamlScannerNode node = new XamlScannerNode(_xmlLineInfo);

            _xmlReader.MoveToContent(); // skip whitespaces
            string xmlData = _xmlReader.ReadInnerXml();

            xmlData          = xmlData.Trim();
            node.NodeType    = ScannerNodeType.TEXT;
            node.IsXDataText = true;
            XamlText xmlText = new XamlText(true);

            xmlText.Paste(xmlData, false);
            node.TextContent = xmlText;
            _readNodesQueue.Enqueue(node);

            // Read InnerXml will advance over the End xData tag and
            // we need to process the current XML state w/o going back for a Read().
            ProcessCurrentXmlNode();
        }
Exemple #3
0
        private void EnqueueAnotherAttribute(bool isEmptyTag)
        {
            XamlAttribute   attr = _attributes[_nextAttribute++];
            XamlScannerNode node = new XamlScannerNode(attr);

            switch (attr.Kind)
            {
            case ScannerAttributeKind.Directive:
            case ScannerAttributeKind.Name:
            case ScannerAttributeKind.CtorDirective:
                node.NodeType = ScannerNodeType.DIRECTIVE;
                break;

            case ScannerAttributeKind.XmlSpace:
                // Empty tags don't have a stack frame to write on.
                // Empty XML tags don't have content to process spaces.
                if (!isEmptyTag)
                {
                    if (KS.Eq(attr.Value, KnownStrings.Preserve))
                    {
                        _scannerStack.CurrentXmlSpacePreserve = true;
                    }
                    else
                    {
                        _scannerStack.CurrentXmlSpacePreserve = false;
                    }
                }
                node.NodeType = ScannerNodeType.DIRECTIVE;
                break;

            case ScannerAttributeKind.Event:
            case ScannerAttributeKind.Property:
                node.IsCtorForcingMember = true;
                node.NodeType            = ScannerNodeType.ATTRIBUTE;
                break;

            case ScannerAttributeKind.Unknown:
                XamlMember prop = attr.Property;
                Debug.Assert(prop.IsUnknown);
                // force use of Ctor for unknown simple properties only
                node.IsCtorForcingMember = !prop.IsAttachable && !prop.IsDirective;
                node.NodeType            = ScannerNodeType.ATTRIBUTE;
                break;

            case ScannerAttributeKind.AttachableProperty:
                node.NodeType = ScannerNodeType.ATTRIBUTE;
                break;

            default:
                throw new XamlInternalException(SR.Get(SRID.AttributeUnhandledKind));
            }

            // (GetFixedDocumentSequence raises Exception "UnicodeString property does not
            // contain enough characters to correspond to the contents of Indices property.")
            //
            // XamlText.Paste normally converts CRLF to LF, even in attribute values.
            // When the property is Glyphs.UnicodeString, disable this;
            // the length of the string must correspond to the number of entries in
            // the corresponding Glyphs.Indices property.
            XamlMember attrProperty    = attr.Property;
            bool       convertCRLFtoLF =
                !(attrProperty != null &&
                  attrProperty.Name == "UnicodeString" &&
                  attrProperty.DeclaringType.Name == "Glyphs");

            node.PropertyAttribute = attrProperty;
            XamlText xamlText = new XamlText(true);  // Don't collapse spaces in attributes

            xamlText.Paste(attr.Value, false, convertCRLFtoLF);
            node.PropertyAttributeText = xamlText;
            node.Prefix = attr.Name.Prefix;

            _readNodesQueue.Enqueue(node);

            if (_nextAttribute >= _attributes.Count)
            {
                _attributes    = null;
                _nextAttribute = -1;
            }
        }
Exemple #4
0
        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 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 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();
 }