示例#1
0
        private IEnumerable <XamlNode> LogicStream_Attribute()
        {
            XamlMember property = _xamlScanner.PropertyAttribute;
            XamlText   text     = _xamlScanner.PropertyAttributeText;

            if (_xamlScanner.IsCtorForcingMember)
            {
                _context.CurrentForcedToUseConstructor = true;
            }

            XamlNode startProperty = new XamlNode(XamlNodeType.StartMember, property);

            yield return(startProperty);

            if (text.LooksLikeAMarkupExtension)
            {
                MePullParser me = new MePullParser(_context);
                foreach (XamlNode node in me.Parse(text.Text, LineNumber, LinePosition))
                {
                    yield return(node);
                }
            }
            else
            {
                XamlNode textNode = new XamlNode(XamlNodeType.Value, text.AttributeText);
                yield return(textNode);
            }
            yield return(new XamlNode(XamlNodeType.EndMember));
        }
        private IEnumerable <XamlNode> LogicStream_Attribute()
        {
            XamlMember propertyAttribute     = this._xamlScanner.PropertyAttribute;
            XamlText   propertyAttributeText = this._xamlScanner.PropertyAttributeText;

            if (this._xamlScanner.IsCtorForcingMember)
            {
                this._context.CurrentForcedToUseConstructor = true;
            }
            XamlNode iteratorVariable2 = new XamlNode(XamlNodeType.StartMember, propertyAttribute);

            yield return(iteratorVariable2);

            if (propertyAttributeText.LooksLikeAMarkupExtension)
            {
                MePullParser iteratorVariable3 = new MePullParser(this._context);
                foreach (XamlNode iteratorVariable4 in iteratorVariable3.Parse(propertyAttributeText.Text, this.LineNumber, this.LinePosition))
                {
                    yield return(iteratorVariable4);
                }
            }
            else
            {
                XamlNode iteratorVariable5 = new XamlNode(XamlNodeType.Value, propertyAttributeText.AttributeText);
                yield return(iteratorVariable5);
            }
            yield return(new XamlNode(XamlNodeType.EndMember));
        }
        private string Logic_ApplyFinalTextTrimming(XamlText text)
        {
            ScannerNodeType peekNodeType = this._xamlScanner.PeekNodeType;
            string          source       = text.Text;

            if (!text.IsSpacePreserved)
            {
                switch (peekNodeType)
                {
                case ScannerNodeType.ENDTAG:
                case ScannerNodeType.PROPERTYELEMENT:
                case ScannerNodeType.EMPTYPROPERTYELEMENT:
                    source = XamlText.TrimTrailingWhitespace(source);
                    break;
                }
                XamlType currentPreviousChildType = this._context.CurrentPreviousChildType;
                if ((currentPreviousChildType == null) || currentPreviousChildType.TrimSurroundingWhitespace)
                {
                    source = XamlText.TrimLeadingWhitespace(source);
                }
                if ((peekNodeType != ScannerNodeType.ELEMENT) && (peekNodeType != ScannerNodeType.EMPTYELEMENT))
                {
                    return(source);
                }
                if (this._xamlScanner.PeekType.TrimSurroundingWhitespace)
                {
                    source = XamlText.TrimTrailingWhitespace(source);
                }
            }
            return(source);
        }
示例#4
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();
        }
示例#5
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();
        }
示例#6
0
        private string Logic_ApplyFinalTextTrimming(XamlText text)
        {
            ScannerNodeType nextNodeType = _xamlScanner.PeekNodeType;
            string          trimmed      = text.Text;

            if (!text.IsSpacePreserved)
            {
                // Trim trailing space from text if it is the last bit of content.
                // End Element and End Property Element and Start of PE all end "content"
                if (nextNodeType == ScannerNodeType.ENDTAG || nextNodeType == ScannerNodeType.PROPERTYELEMENT || nextNodeType == ScannerNodeType.EMPTYPROPERTYELEMENT)
                {
                    trimmed = XamlText.TrimTrailingWhitespace(trimmed);
                }

                // If the text is the first thing, ie. before any element
                // OR the previous element was "TrimSurroundingWhitespace"
                // then trim leading Whitespace.
                XamlType previousObject = _context.CurrentPreviousChildType;
                if (previousObject == null || previousObject.TrimSurroundingWhitespace)
                {
                    trimmed = XamlText.TrimLeadingWhitespace(trimmed);
                }

                // If next element is "TrimSurroundingWhitespace", trim trailing WS.
                if (nextNodeType == ScannerNodeType.ELEMENT ||
                    nextNodeType == ScannerNodeType.EMPTYELEMENT)
                {
                    XamlType nextXamlType = _xamlScanner.PeekType;
                    if (nextXamlType.TrimSurroundingWhitespace)
                    {
                        trimmed = XamlText.TrimTrailingWhitespace(trimmed);
                    }
                }
            }
            return(trimmed);
        }
示例#7
0
 private void ClearAccumulatedText()
 {
     _accumulatedText = null;
 }
示例#8
0
        ///////////////////////////
        //  PropertyContent ::= ( PREFIXDEFINITION* Element ) | TEXT
        //
        public IEnumerable <XamlNode> P_PropertyContent()
        {
            ScannerNodeType nodeType = _xamlScanner.NodeType;
            List <XamlNode> _savedPrefixDefinitions = null;
            string          trimmed   = string.Empty;
            bool            isTextXML = false;

            switch (nodeType)
            {
            case ScannerNodeType.PREFIXDEFINITION:
            case ScannerNodeType.ELEMENT:
            case ScannerNodeType.EMPTYELEMENT:
            case ScannerNodeType.TEXT:
                if (nodeType == ScannerNodeType.TEXT)
                {
                    XamlText text = _xamlScanner.TextContent;

                    if (Logic_IsDiscardableWhitespace(text))
                    {
                        trimmed = string.Empty;
                    }
                    else
                    {
                        trimmed = Logic_ApplyFinalTextTrimming(text);
                    }

                    isTextXML = _xamlScanner.IsXDataText;
                    _xamlScanner.Read();
                    if (ProvideLineInfo)
                    {
                        yield return(Logic_LineInfo());
                    }
                    if (trimmed == string.Empty)
                    {
                        break;
                    }
                }

                // Don't immediately emit the prefix Definitions.
                // buffer them for moment because if this is the first object
                // in a collection, we may need to jam an implicit _Items property
                // in before the PrefixDef's and then the ObjectType.
                while (nodeType == ScannerNodeType.PREFIXDEFINITION)
                {
                    if (_savedPrefixDefinitions == null)
                    {
                        _savedPrefixDefinitions = new List <XamlNode>();
                    }
                    _savedPrefixDefinitions.Add(Logic_PrefixDefinition());
                    if (ProvideLineInfo)
                    {
                        _savedPrefixDefinitions.Add(Logic_LineInfo());
                    }
                    _xamlScanner.Read();
                    if (ProvideLineInfo)
                    {
                        yield return(Logic_LineInfo());
                    }
                    nodeType = _xamlScanner.NodeType;
                }

                // If this is TEXT and the current Property has a TypeConverter
                // Then emit the TEXT now.
                if (nodeType == ScannerNodeType.TEXT &&
                    _context.CurrentMember.TypeConverter != null)
                {
                    yield return(new XamlNode(XamlNodeType.Value, trimmed));
                }
                else
                {
                    // Check for any preambles we need to emit before the
                    // emitting the actual element or Text.
                    if (!_context.CurrentInCollectionFromMember)
                    {
                        // Check for and emit the get collection from member.
                        foreach (XamlNode node in LogicStream_CheckForStartGetCollectionFromMember())
                        {
                            yield return(node);
                        }
                    }

                    // We couldn't emit text in the code above (directly under the property).
                    // We have now (possibly) started a get collection from member.  This TEXT might go
                    // under the _items.
                    // This might be <XDATA>.
                    // It might still be an error, ie. Unknown Content.
                    // This is the last chance to emit the TEXT.
                    if (nodeType == ScannerNodeType.TEXT)
                    {
                        if (isTextXML)
                        {
                            yield return(Logic_StartObject(XamlLanguage.XData, null));

                            XamlMember xDataTextProperty = XamlLanguage.XData.GetMember("Text");
                            yield return(Logic_EndOfAttributes());

                            yield return(Logic_StartMember(xDataTextProperty));
                        }

                        yield return(new XamlNode(XamlNodeType.Value, trimmed));

                        if (isTextXML)
                        {
                            yield return(Logic_EndMember());

                            yield return(Logic_EndObject());
                        }
                    }
                    else
                    {
                        // Now we are ready for the given element.
                        // now emit the saved prefix definitions.
                        if (_savedPrefixDefinitions != null)
                        {
                            for (int i = 0; i < _savedPrefixDefinitions.Count; i++)
                            {
                                yield return(_savedPrefixDefinitions[i]);
                            }
                        }

                        foreach (XamlNode node in P_Element())
                        {
                            yield return(node);
                        }
                    }
                }
                break;
            }
        }
示例#9
0
        ///////////////////////////
        //  ElementContent ::= ( PREFIXDEFINITION* Element ) | TEXT
        //
        public IEnumerable <XamlNode> P_ElementContent()
        {
            XamlType currentType = _context.CurrentType;

            List <XamlNode> savedPrefixDefinitions = null;
            ScannerNodeType nodeType = _xamlScanner.NodeType;

            switch (nodeType)
            {
            case ScannerNodeType.PREFIXDEFINITION:
            case ScannerNodeType.ELEMENT:
            case ScannerNodeType.EMPTYELEMENT:
            case ScannerNodeType.TEXT:
                if (nodeType == ScannerNodeType.TEXT)
                {
                    XamlText text = _xamlScanner.TextContent;

                    if (Logic_IsDiscardableWhitespace(text))
                    {
                        _xamlScanner.Read();
                        if (ProvideLineInfo)
                        {
                            yield return(Logic_LineInfo());
                        }
                        break;
                    }
                }

                // Don't immediately emit the prefix Definitions.
                // buffer them for moment because if this is the first object
                // in a collection, we may need to jam an implicit _Items property
                // on Content Property in before the PrefixDef's and then the ObjectType.
                while (nodeType == ScannerNodeType.PREFIXDEFINITION)
                {
                    if (savedPrefixDefinitions == null)
                    {
                        savedPrefixDefinitions = new List <XamlNode>();
                    }
                    if (ProvideLineInfo)
                    {
                        savedPrefixDefinitions.Add(Logic_LineInfo());
                    }
                    savedPrefixDefinitions.Add(Logic_PrefixDefinition());
                    _xamlScanner.Read();
                    if (ProvideLineInfo)
                    {
                        yield return(Logic_LineInfo());
                    }
                    nodeType = _xamlScanner.NodeType;
                }

                // Check for any preambles we need to emit before the
                // emitting the actual element or Text.
                bool isTextInitialization = false;
                if (!_context.CurrentInItemsProperty && !_context.CurrentInUnknownContent)
                {
                    bool isContentProperty = false;
                    // In case of text, we look first for a string or object content property,
                    // then a TypeConverter
                    if (nodeType == ScannerNodeType.TEXT)
                    {
                        if (currentType.ContentProperty != null && CanAcceptString(currentType.ContentProperty))
                        {
                            isContentProperty = true;
                        }
                        // If there have been "real" properties then we are forced to use the
                        // Constructor.  Otherwise we can consider a TypeConverter on the TEXT.
                        else if (!_context.CurrentForcedToUseConstructor &&
                                 !_xamlScanner.TextContent.IsEmpty &&
                                 currentType.TypeConverter != null)
                        {
                            isTextInitialization = true;
                        }
                    }
                    // Otherwise, we look first for a collection, and then fall back to content property
                    if (!isTextInitialization && !isContentProperty)
                    {
                        // If we are first in a collection
                        if (currentType.IsCollection || currentType.IsDictionary)
                        {
                            yield return(Logic_StartItemsProperty(currentType));
                        }
                        else  // Back to ContentProperty (either element or unknown content)
                        {
                            isContentProperty = true;
                        }
                    }
                    // Don't yield more than one unknown content property for multiple,
                    // contiguous content objects and values.
                    if (isContentProperty && !_context.CurrentInUnknownContent)
                    {
                        XamlMember contentProperty = currentType.ContentProperty;
                        if (contentProperty != null)
                        {
                            bool isVisible = _context.IsVisible(
                                contentProperty, _context.CurrentTypeIsRoot ? _context.CurrentType : null);
                            // Visible content properties produce known members.
                            // Invisible content properties produce unknown members.
                            // Protected content properties of root instances and internal
                            // content properties can be visible, depending on the reader settings.
                            if (!isVisible)
                            {
                                // We use the current type, not the actual declaring type of the non-visible property,
                                // for consistency with how non-visible PEs and Attribute Properties are handled.
                                contentProperty = new XamlMember(contentProperty.Name, currentType, false);
                            }
                        }
                        // A null argument produces an unknown content member.
                        yield return(Logic_StartContentProperty(contentProperty));

                        // Check for and emit the get collection from member.
                        foreach (XamlNode node in LogicStream_CheckForStartGetCollectionFromMember())
                        {
                            yield return(node);
                        }
                    }
                }

                // Now we are ready for the given element.
                // so now emit the saved prefix definitions.
                if (savedPrefixDefinitions != null)
                {
                    for (int i = 0; i < savedPrefixDefinitions.Count; i++)
                    {
                        yield return(savedPrefixDefinitions[i]);
                    }
                    if (ProvideLineInfo)
                    {
                        yield return(Logic_LineInfo());
                    }
                }

                if (nodeType == ScannerNodeType.TEXT)
                {
                    XamlText text        = _xamlScanner.TextContent;
                    string   trimmed     = Logic_ApplyFinalTextTrimming(text);
                    bool     isXDataText = _xamlScanner.IsXDataText;
                    _xamlScanner.Read();
                    if (ProvideLineInfo)
                    {
                        yield return(Logic_LineInfo());
                    }

                    if (trimmed == string.Empty)
                    {
                        break;
                    }

                    if (isTextInitialization)
                    {
                        yield return(Logic_StartInitProperty(currentType));
                    }

                    if (isXDataText)
                    {
                        yield return(Logic_StartObject(XamlLanguage.XData, null));

                        XamlMember xDataTextProperty = XamlLanguage.XData.GetMember("Text");
                        yield return(Logic_EndOfAttributes());

                        yield return(Logic_StartMember(xDataTextProperty));
                    }

                    yield return(new XamlNode(XamlNodeType.Value, trimmed));

                    if (isXDataText)
                    {
                        yield return(Logic_EndMember());

                        yield return(Logic_EndObject());
                    }
                }
                else
                {
                    foreach (XamlNode node in P_Element())
                    {
                        yield return(node);
                    }
                }

                // If we are not in an items or unknown content property, then
                // there cannot be more objects or values that follow this content
                // (a singular property), and thus we can end this property now.
                if (!_context.CurrentInItemsProperty && !_context.CurrentInUnknownContent)
                {
                    yield return(Logic_EndMember());
                }
                break;
            } // end switch
        }
示例#10
0
 /// <summary>
 /// Returns true if whitespace is discardable at this phase in
 /// the parsing.  Here we discard whitespace between property elements
 /// but keep it between object elements for collections that accept it.
 /// Discarding trailing whitespace in collections cannot be decided here.
 /// [see: Logic_ReadAhead_ApplyFinalTextTrimming
 /// </summary>
 /// <param name="text"></param>
 /// <returns></returns>
 private bool Logic_IsDiscardableWhitespace(XamlText text)
 {
     if (!text.IsWhiteSpaceOnly)
     {
         return(false);
     }
     else
     {
         // Force unknown members to behave as whitespace significant collections in order to preserve as much information as possible.
         if (_context.CurrentMember != null && _context.CurrentMember.IsUnknown)
         {
             return(false);
         }
         else if (_context.CurrentInContainerDirective)
         {
             XamlType collectionType = _context.CurrentMember == XamlLanguage.Items ? _context.CurrentType : _context.CurrentMember.Type;
             if (collectionType.IsWhitespaceSignificantCollection)
             {
                 return(false);
             }
         }
         else
         {
             // Whitespace, by itself does not start content.  Eg. The WS between
             // the Start Element and the first Property Element is not content, but
             // the WS between the Start Element and the first child Element (ie. other content)
             // is content.
             XamlMember prop = _context.CurrentMember;
             if (_xamlScanner.PeekNodeType == ScannerNodeType.ELEMENT)
             {
                 if (prop == null)
                 {
                     prop = _context.CurrentType.ContentProperty;
                 }
                 if (prop != null && prop.Type != null && prop.Type.IsWhitespaceSignificantCollection)
                 {
                     return(false);
                 }
                 if (prop == null && _context.CurrentType.IsWhitespaceSignificantCollection)
                 {
                     return(false);
                 }
             }
             // Whitespace can also start content if space is preserved and it's at the end of an element and...
             else if (text.IsSpacePreserved && _xamlScanner.PeekNodeType == ScannerNodeType.ENDTAG)
             {
                 // ...it's by itself in a PE with no other children
                 if (prop != null)
                 {
                     if (_context.CurrentPreviousChildType == null)
                     {
                         return(false);
                     }
                 }
                 // ...it's in an element with a string content property
                 else if (_context.CurrentType.ContentProperty != null)
                 {
                     prop = _context.CurrentType.ContentProperty;
                     // For backcompat we need to support CPs of type object here.
                     // Theoretically we'd also like to support all type-convertible CPs.
                     // However, for non-string CPs, 3.0 only surfaced whitespace as text if
                     // the CP hadn't already been set. For string, it surfaced it in all cases.
                     // So to avoid a breaking change, we only surface string right now.
                     if (prop.Type == XamlLanguage.String)
                     {
                         return(false);
                     }
                     if (prop.Type.IsWhitespaceSignificantCollection)
                     {
                         return(false);
                     }
                 }
                 // ...it's in a type-convertible element
                 else if (_context.CurrentType.TypeConverter != null && !_context.CurrentForcedToUseConstructor)
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
 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();
 }
        public IEnumerable <XamlNode> P_PropertyContent()
        {
            ScannerNodeType nodeType          = this._xamlScanner.NodeType;
            List <XamlNode> iteratorVariable1 = null;
            string          data      = string.Empty;
            bool            isTextXML = false;

            switch (nodeType)
            {
            default:
            {
                goto Label_04E6;
                if (nodeType != ScannerNodeType.TEXT)
                {
                    break;
                }
                XamlText textContent = this._xamlScanner.TextContent;
                if (this.Logic_IsDiscardableWhitespace(textContent))
                {
                    data = string.Empty;
                }
                else
                {
                    data = this.Logic_ApplyFinalTextTrimming(textContent);
                }
                isTextXML = this._xamlScanner.IsTextXML;
                this._xamlScanner.Read();
                if (this.ProvideLineInfo)
                {
                    yield return(this.Logic_LineInfo());
                }
                if (!(data == string.Empty))
                {
                    break;
                }
                goto Label_04E6;
            }
            }
            while (nodeType == ScannerNodeType.PREFIXDEFINITION)
            {
                if (iteratorVariable1 == null)
                {
                    iteratorVariable1 = new List <XamlNode>();
                }
                iteratorVariable1.Add(this.Logic_PrefixDefinition());
                if (this.ProvideLineInfo)
                {
                    iteratorVariable1.Add(this.Logic_LineInfo());
                }
                this._xamlScanner.Read();
                if (this.ProvideLineInfo)
                {
                    yield return(this.Logic_LineInfo());
                }
                nodeType = this._xamlScanner.NodeType;
            }
            if ((nodeType == ScannerNodeType.TEXT) && (this._context.CurrentMember.TypeConverter != null))
            {
                yield return(new XamlNode(XamlNodeType.Value, data));
            }
            else
            {
                if (!this._context.CurrentInCollectionFromMember)
                {
                    foreach (XamlNode iteratorVariable5 in this.LogicStream_CheckForStartGetCollectionFromMember())
                    {
                        yield return(iteratorVariable5);
                    }
                }
                if (nodeType == ScannerNodeType.TEXT)
                {
                    if (isTextXML)
                    {
                        yield return(this.Logic_StartObject(XamlLanguage.XData, null));

                        XamlMember member = XamlLanguage.XData.GetMember("Text");
                        yield return(this.Logic_EndOfAttributes());

                        yield return(this.Logic_StartMember(member));
                    }
                    yield return(new XamlNode(XamlNodeType.Value, data));

                    if (isTextXML)
                    {
                        yield return(this.Logic_EndMember());

                        yield return(this.Logic_EndObject());
                    }
                }
                else
                {
                    if (iteratorVariable1 != null)
                    {
                        for (int i = 0; i < iteratorVariable1.Count; i++)
                        {
                            yield return(iteratorVariable1[i]);
                        }
                    }
                    foreach (XamlNode iteratorVariable8 in this.P_Element())
                    {
                        yield return(iteratorVariable8);
                    }
                }
            }
Label_04E6:
            yield break;
        }
        public IEnumerable <XamlNode> P_ElementContent()
        {
            XamlType        currentType       = this._context.CurrentType;
            List <XamlNode> iteratorVariable1 = null;
            ScannerNodeType nodeType          = this._xamlScanner.NodeType;

            switch (nodeType)
            {
            default:
            {
                goto Label_0727;
                if (nodeType != ScannerNodeType.TEXT)
                {
                    break;
                }
                XamlText textContent = this._xamlScanner.TextContent;
                if (!this.Logic_IsDiscardableWhitespace(textContent))
                {
                    break;
                }
                this._xamlScanner.Read();
                if (this.ProvideLineInfo)
                {
                    yield return(this.Logic_LineInfo());
                }
                goto Label_0727;
            }
            }
            while (nodeType == ScannerNodeType.PREFIXDEFINITION)
            {
                if (iteratorVariable1 == null)
                {
                    iteratorVariable1 = new List <XamlNode>();
                }
                iteratorVariable1.Add(this.Logic_PrefixDefinition());
                if (this.ProvideLineInfo)
                {
                    iteratorVariable1.Add(this.Logic_LineInfo());
                }
                this._xamlScanner.Read();
                if (this.ProvideLineInfo)
                {
                    yield return(this.Logic_LineInfo());
                }
                nodeType = this._xamlScanner.NodeType;
            }
            bool iteratorVariable4 = false;

            if (!this._context.CurrentInItemsProperty)
            {
                bool iteratorVariable5 = false;
                if (nodeType == ScannerNodeType.TEXT)
                {
                    if ((currentType.ContentProperty != null) && CanAcceptString(currentType.ContentProperty))
                    {
                        iteratorVariable5 = true;
                    }
                    else if ((!this._context.CurrentForcedToUseConstructor && !this._xamlScanner.TextContent.IsEmpty) && (currentType.TypeConverter != null))
                    {
                        iteratorVariable4 = true;
                    }
                }
                if (!iteratorVariable4 && !iteratorVariable5)
                {
                    if (currentType.IsCollection || currentType.IsDictionary)
                    {
                        yield return(this.Logic_StartItemsProperty(currentType));
                    }
                    else
                    {
                        iteratorVariable5 = true;
                    }
                }
                if (iteratorVariable5 && !this._context.CurrentIsUnknownContent)
                {
                    XamlMember contentProperty = currentType.ContentProperty;
                    if ((contentProperty != null) && !this._context.IsVisible(contentProperty, this._context.CurrentTypeIsRoot ? this._context.CurrentType : null))
                    {
                        contentProperty = new XamlMember(contentProperty.Name, currentType, false);
                    }
                    yield return(this.Logic_StartContentProperty(contentProperty));

                    foreach (XamlNode iteratorVariable7 in this.LogicStream_CheckForStartGetCollectionFromMember())
                    {
                        yield return(iteratorVariable7);
                    }
                }
            }
            if (iteratorVariable1 != null)
            {
                for (int i = 0; i < iteratorVariable1.Count; i++)
                {
                    yield return(iteratorVariable1[i]);
                }
            }
            if (nodeType == ScannerNodeType.TEXT)
            {
                XamlText text      = this._xamlScanner.TextContent;
                string   data      = this.Logic_ApplyFinalTextTrimming(text);
                bool     isTextXML = this._xamlScanner.IsTextXML;
                this._xamlScanner.Read();
                if (this.ProvideLineInfo)
                {
                    yield return(this.Logic_LineInfo());
                }
                if (data == string.Empty)
                {
                    goto Label_0727;
                }
                if (iteratorVariable4)
                {
                    yield return(this.Logic_StartInitProperty(currentType));
                }
                if (isTextXML)
                {
                    yield return(this.Logic_StartObject(XamlLanguage.XData, null));

                    XamlMember member = XamlLanguage.XData.GetMember("Text");
                    yield return(this.Logic_EndOfAttributes());

                    yield return(this.Logic_StartMember(member));
                }
                yield return(new XamlNode(XamlNodeType.Value, data));

                if (isTextXML)
                {
                    yield return(this.Logic_EndMember());

                    yield return(this.Logic_EndObject());
                }
            }
            else
            {
                IEnumerator <XamlNode> enumerator = this.P_Element().GetEnumerator();
                while (enumerator.MoveNext())
                {
                    XamlNode current = enumerator.Current;
                    yield return(current);
                }
            }
            if (!this._context.CurrentInItemsProperty && !this._context.CurrentIsUnknownContent)
            {
                yield return(this.Logic_EndMember());
            }
Label_0727:
            yield break;
        }
 private bool Logic_IsDiscardableWhitespace(XamlText text)
 {
     if (!text.IsWhiteSpaceOnly)
     {
         return(false);
     }
     if ((this._context.CurrentMember != null) && this._context.CurrentMember.IsUnknown)
     {
         return(false);
     }
     if (this._context.CurrentInContainerDirective)
     {
         XamlType type = (this._context.CurrentMember == XamlLanguage.Items) ? this._context.CurrentType : this._context.CurrentMember.Type;
         if (type.IsWhitespaceSignificantCollection)
         {
             return(false);
         }
     }
     else
     {
         XamlMember currentMember = this._context.CurrentMember;
         if (this._xamlScanner.PeekNodeType == ScannerNodeType.ELEMENT)
         {
             if (currentMember == null)
             {
                 currentMember = this._context.CurrentType.ContentProperty;
             }
             if (((currentMember != null) && (currentMember.Type != null)) && currentMember.Type.IsWhitespaceSignificantCollection)
             {
                 return(false);
             }
             if ((currentMember == null) && this._context.CurrentType.IsWhitespaceSignificantCollection)
             {
                 return(false);
             }
         }
         else if (text.IsSpacePreserved && (this._xamlScanner.PeekNodeType == ScannerNodeType.ENDTAG))
         {
             if (currentMember != null)
             {
                 if (this._context.CurrentPreviousChildType == null)
                 {
                     return(false);
                 }
             }
             else if (this._context.CurrentType.ContentProperty != null)
             {
                 currentMember = this._context.CurrentType.ContentProperty;
                 if (currentMember.Type == XamlLanguage.String)
                 {
                     return(false);
                 }
                 if (currentMember.Type.IsWhitespaceSignificantCollection)
                 {
                     return(false);
                 }
             }
             else if ((this._context.CurrentType.TypeConverter != null) && !this._context.CurrentForcedToUseConstructor)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
        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;
            }
        }
示例#16
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;
            }
        }
示例#17
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;
            }
        }
 private void ClearAccumulatedText()
 {
     this._accumulatedText = null;
 }