private bool MoveFirstChild(BamlNodeType type)
        {
            var node = _state.Node;

            if (!node.IsBlock)
            {
                return(false);
            }

            var nextNode = ((BamlBlock)node).FirstChild;

            while (nextNode != null && IsSkipNode(nextNode))
            {
                nextNode = nextNode.NextSibling;
            }

            if (nextNode == null)
            {
                return(false);
            }

            if (nextNode.NodeType != type)
            {
                return(false);
            }

            MoveNext();
            return(true);
        }
        // Token: 0x06006EB6 RID: 28342 RVA: 0x001FCF00 File Offset: 0x001FB100
        internal bool TryGetContent(BamlLocalizableResourceKey key, BamlTreeNode currentNode, out string content)
        {
            content = string.Empty;
            BamlNodeType nodeType = currentNode.NodeType;

            if (nodeType == BamlNodeType.StartElement)
            {
                BamlStartElementNode bamlStartElementNode = (BamlStartElementNode)currentNode;
                if (bamlStartElementNode.Content == null)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (BamlTreeNode bamlTreeNode in bamlStartElementNode.Children)
                    {
                        nodeType = bamlTreeNode.NodeType;
                        if (nodeType != BamlNodeType.StartElement)
                        {
                            if (nodeType == BamlNodeType.Text)
                            {
                                stringBuilder.Append(BamlResourceContentUtil.EscapeString(((BamlTextNode)bamlTreeNode).Content));
                            }
                        }
                        else
                        {
                            string value;
                            if (!this.TryFormatElementContent(key, (BamlStartElementNode)bamlTreeNode, out value))
                            {
                                return(false);
                            }
                            stringBuilder.Append(value);
                        }
                    }
                    bamlStartElementNode.Content = stringBuilder.ToString();
                }
                content = bamlStartElementNode.Content;
                return(true);
            }
            if (nodeType == BamlNodeType.Property)
            {
                bool             result           = true;
                BamlPropertyNode bamlPropertyNode = (BamlPropertyNode)currentNode;
                content = BamlResourceContentUtil.EscapeString(bamlPropertyNode.Value);
                string text = content;
                string text2;
                string text3;
                if (MarkupExtensionParser.GetMarkupExtensionTypeAndArgs(ref text, out text2, out text3))
                {
                    LocalizabilityGroup localizabilityComment = this._resolver.GetLocalizabilityComment(bamlPropertyNode.Parent as BamlStartElementNode, bamlPropertyNode.PropertyName);
                    result = (localizabilityComment != null && localizabilityComment.Readability == Readability.Readable);
                }
                return(result);
            }
            if (nodeType != BamlNodeType.LiteralContent)
            {
                return(true);
            }
            content = BamlResourceContentUtil.EscapeString(((BamlLiteralContentNode)currentNode).Content);
            return(true);
        }
示例#3
0
        // Token: 0x06006E21 RID: 28193 RVA: 0x001FB3C4 File Offset: 0x001F95C4
        internal static BamlLocalizableResourceKey GetKey(BamlTreeNode node)
        {
            BamlLocalizableResourceKey result = null;
            BamlNodeType nodeType             = node.NodeType;

            if (nodeType != BamlNodeType.StartElement)
            {
                if (nodeType != BamlNodeType.Property)
                {
                    if (nodeType == BamlNodeType.LiteralContent)
                    {
                        BamlLiteralContentNode bamlLiteralContentNode = (BamlLiteralContentNode)node;
                        BamlStartElementNode   bamlStartElementNode   = (BamlStartElementNode)node.Parent;
                        if (bamlStartElementNode.Uid != null)
                        {
                            result = new BamlLocalizableResourceKey(bamlStartElementNode.Uid, bamlStartElementNode.TypeFullName, "$LiteralContent", bamlStartElementNode.AssemblyName);
                        }
                    }
                }
                else
                {
                    BamlPropertyNode     bamlPropertyNode      = (BamlPropertyNode)node;
                    BamlStartElementNode bamlStartElementNode2 = (BamlStartElementNode)bamlPropertyNode.Parent;
                    if (bamlStartElementNode2.Uid != null)
                    {
                        string uid;
                        if (bamlPropertyNode.Index <= 0)
                        {
                            uid = bamlStartElementNode2.Uid;
                        }
                        else
                        {
                            uid = string.Format(TypeConverterHelper.InvariantEnglishUS, "{0}.{1}_{2}", new object[]
                            {
                                bamlStartElementNode2.Uid,
                                bamlPropertyNode.PropertyName,
                                bamlPropertyNode.Index
                            });
                        }
                        result = new BamlLocalizableResourceKey(uid, bamlPropertyNode.OwnerTypeFullName, bamlPropertyNode.PropertyName, bamlPropertyNode.AssemblyName);
                    }
                }
            }
            else
            {
                BamlStartElementNode bamlStartElementNode3 = (BamlStartElementNode)node;
                if (bamlStartElementNode3.Uid != null)
                {
                    result = new BamlLocalizableResourceKey(bamlStartElementNode3.Uid, bamlStartElementNode3.TypeFullName, "$Content", bamlStartElementNode3.AssemblyName);
                }
            }
            return(result);
        }
        private bool MoveNext(BamlNodeType type)
        {
            var next = GetNext(_state.Node);

            if (next == null)
            {
                return(false);
            }

            if (next.NodeType != type)
            {
                return(false);
            }

            MoveNext();
            return(true);
        }
        /***************************************************************************\
        *
        * BamlReader.ReadElementEndRecord
        *
        * Read the end of an element.  This is either a CLR or DependencyObject
        * that is part of an object tree.
        *
        \***************************************************************************/

        private void ReadElementEndRecord()
        {
            // If we are processing a deferable content block and we've reached the
            // end record for the deferable element, then pop off the deferable content
            // start record that is on the stack.
            if (_deferableContentBlockDepth == _nodeStack.Count)
            {
                _deferableContentBlockDepth = -1;
                _deferableContentPosition = -1;
            }

            // Pop information off the node stack that tells us what element this
            // is the end of.  Check to make sure the record on the stack is for a
            // start element.
            BamlNodeInfo nodeInfo = (BamlNodeInfo)_nodeStack.Pop();
            if (nodeInfo.RecordType != BamlRecordType.ElementStart)
            {
                throw new InvalidOperationException(SR.Get(SRID.BamlScopeError,
                                                 _currentBamlRecord.RecordType.ToString(),
                                                 BamlRecordType.ElementEnd.ToString()));
            }

            ClearProperties();
            NodeTypeInternal = BamlNodeType.EndElement;
            _name = nodeInfo.Name;
            _localName = nodeInfo.LocalName;
            _ownerTypeName = string.Empty;
            _assemblyName = nodeInfo.AssemblyName;
            _prefix = nodeInfo.Prefix;
            _xmlNamespace = nodeInfo.XmlNamespace;
            _clrNamespace = nodeInfo.ClrNamespace;
            _parserContext.PopScope();
            _prefixDictionary.PopScope();

            // read properties, if any, after this end tag.
            ReadProperties();

        }
        /***************************************************************************\
        *
        * BamlReader.ReadElementStartRecord
        *
        * Read the start of an element.  This is either a CLR or DependencyObject
        * that is part of an object tree.
        *
        \***************************************************************************/

        private void ReadElementStartRecord()
        {
            ClearProperties();
            _propertyDP = null;
            _parserContext.PushScope();
            _prefixDictionary.PushScope();

            BamlElementStartRecord bamlRecord = (BamlElementStartRecord)_currentBamlRecord;
            BamlTypeInfoRecord typeInfo = MapTable.GetTypeInfoFromId(bamlRecord.TypeId);

            NodeTypeInternal = BamlNodeType.StartElement;
            _name = typeInfo.TypeFullName;
            _localName = _name.Substring(_name.LastIndexOf(".", StringComparison.Ordinal) + 1);
            _ownerTypeName = string.Empty;
            _clrNamespace = typeInfo.ClrNamespace;
            GetAssemblyAndPrefixAndXmlns(typeInfo, out _assemblyName, out _prefix, out _xmlNamespace);

            // Push information on the node stack to indicate we have a start element
            BamlNodeInfo nodeInfo = new BamlNodeInfo();
            nodeInfo.Name = _name;
            nodeInfo.LocalName = _localName;
            nodeInfo.AssemblyName = _assemblyName;
            nodeInfo.Prefix = _prefix;
            nodeInfo.ClrNamespace = _clrNamespace;
            nodeInfo.XmlNamespace = _xmlNamespace;
            nodeInfo.RecordType = BamlRecordType.ElementStart;

            _useTypeConverter = bamlRecord.CreateUsingTypeConverter;
            _isInjected = bamlRecord.IsInjected;

            // If we are in a deferable block, then see if this is a top level element for
            // that block that matches an offset in the list of defered dictionary keys.  If
            // so, then insert a x:Key="keystring" to make this appear like a normal
            // dictionary.
            if (_deferableContentBlockDepth == _nodeStack.Count)
            {
                // Calculate the offset for the start of the current element record in
                // the baml stream.
                Int32 offset = (Int32)(_bamlRecordReader.StreamPosition - _deferableContentPosition);

                // Subtract off the size of the current Record.
                offset -= bamlRecord.RecordSize + BamlRecord.RecordTypeFieldLength;

                // If there is a debug extension record then subtract that off also.
                if (BamlRecordHelper.HasDebugExtensionRecord(_parserContext.IsDebugBamlStream, bamlRecord))
                {
                    BamlRecord bamlDebugRecord = bamlRecord.Next;
                    offset -= bamlDebugRecord.RecordSize + BamlRecord.RecordTypeFieldLength;
                }
                InsertDeferedKey(offset);
            }

            _nodeStack.Push(nodeInfo);

            // Read the properties that may be part of the start tag of this element
            ReadProperties();
        }
        /***************************************************************************\
        *
        * BamlReader.ReadLiteralContentRecord
        *
        * Read literal content record, which is the responsibility of the current
        * element to parse.
        *
        \***************************************************************************/

        private void ReadLiteralContentRecord()
        {
            ClearProperties();

            BamlLiteralContentRecord bamlRecord = (BamlLiteralContentRecord)_currentBamlRecord;
            NodeTypeInternal = BamlNodeType.LiteralContent;
            _value = bamlRecord.Value;
        }
        /***************************************************************************\
        *
        * BamlReader.ReadPIMappingRecord
        *
        * Read the clr to xml namespace to assembly mapping record.  The contents
        * of this record are represented as three properties, one each for
        * XmlNamespace, ClrNamespace and Assembly Name.
        *
        \***************************************************************************/

        private void ReadPIMappingRecord()
        {
            BamlPIMappingRecord piMappingRecord = (BamlPIMappingRecord)_currentBamlRecord;
            BamlAssemblyInfoRecord assemblyInfo = MapTable.GetAssemblyInfoFromId(
                                                                  piMappingRecord.AssemblyId);
            if (assemblyInfo == null)
            {
                throw new InvalidOperationException(SR.Get(SRID.ParserMapPIMissingAssembly));
            }

            // If this mapping has not already been set up, then set it now
            if (!_parserContext.XamlTypeMapper.PITable.Contains(piMappingRecord.XmlNamespace))
            {
                // Add information to the MappingPI hashtable and the reverse lookup
                // hashtable.
                _parserContext.XamlTypeMapper.AddMappingProcessingInstruction(piMappingRecord.XmlNamespace,
                                                   piMappingRecord.ClrNamespace,
                                                   assemblyInfo.AssemblyFullName);
            }

            ClearProperties();
            NodeTypeInternal = BamlNodeType.PIMapping;
            _name = "Mapping";
            _localName = _name;
            _ownerTypeName = string.Empty;

            // Set the xml namespace, clr namespace and assembly properties as defined
            // in the mapping PI.
            _xmlNamespace = piMappingRecord.XmlNamespace;
            _clrNamespace = piMappingRecord.ClrNamespace;
            _assemblyName = assemblyInfo.AssemblyFullName;

            StringBuilder valueBuilder = new StringBuilder(100);
            valueBuilder.Append("XmlNamespace=\"");
            valueBuilder.Append(_xmlNamespace);
            valueBuilder.Append("\" ClrNamespace=\"");
            valueBuilder.Append(_clrNamespace);
            valueBuilder.Append("\" Assembly=\"");
            valueBuilder.Append(_assemblyName);
            valueBuilder.Append("\"");
            _value = valueBuilder.ToString();

        }
 public T FindPreviousSibling <T>(BamlNodeType type, bool throwIfMissing = false)
     where T : BamlNode
 {
     return((T)FindPreviousSibling(n => n.NodeType == type, throwIfMissing));
 }
示例#10
0
        /***************************************************************************\
        *
        * BamlReader.ReadNextRecord
        *
        * Read the next record, setting the ReadState, NodeType and other pertinent
        * information about the record just read.
        *
        \***************************************************************************/

        private void ReadNextRecord()
        {
            // If this is the first call to Read.  Then read the Version Header.
            if(_readState == ReadState.Initial)
            {
                _bamlRecordReader.ReadVersionHeader();
            }

            // We'll read in a loop until we get to a significant record.  Note that Assembly,
            // Type and Attribute records are read and processed, but the BamlReader never stops
            // on one of these records, since they are not externally exposed.
            bool keepOnReading = true;
            while (keepOnReading)
            {
                // We may already have a record that was previously read in but not
                // processed.  This occurs when we've looped through all the properties
                // on an element and have encountered a non-property record to stop
                // the loop.  In that case don't read another record and just process
                // the one we have.
                if (_haveUnprocessedRecord)
                {
                    _haveUnprocessedRecord = false;
                }
                else
                {
                    GetNextRecord();
                }

                // If the current baml record is null, then the stream is finished, closed
                // or something else that prevents us reading further, so treat this
                // as an end-of-file condition
                if (_currentBamlRecord == null)
                {
                    NodeTypeInternal = BamlNodeType.None;
                    _readState = ReadState.EndOfFile;
                    ClearProperties();
                    return;
                }


                // By default, the read state is interactive after a record has been read, and we
                // should stop reading after this record is processed.  This may be altered for
                // specific record types.
                _readState = ReadState.Interactive;
                keepOnReading = false;

                switch (_currentBamlRecord.RecordType)
                {
                    // The following three records are internal to the BAMLReader and
                    // are not exposed publicly.  They are used to update the map table
                    // that maps ids to assemblies, types and attributes.
                    case BamlRecordType.AssemblyInfo:
                        ReadAssemblyInfoRecord();
                        keepOnReading = true;
                        break;

                    case BamlRecordType.TypeInfo:
                    case BamlRecordType.TypeSerializerInfo:
                        MapTable.LoadTypeInfoRecord((BamlTypeInfoRecord)_currentBamlRecord);
                        keepOnReading = true;
                        break;

                    case BamlRecordType.AttributeInfo:
                        MapTable.LoadAttributeInfoRecord((BamlAttributeInfoRecord)_currentBamlRecord);
                        keepOnReading = true;
                        break;

                    case BamlRecordType.StringInfo:
                        MapTable.LoadStringInfoRecord((BamlStringInfoRecord)_currentBamlRecord);
                        keepOnReading = true;
                        break;

                    case BamlRecordType.ContentProperty:
                        // This is just a cache of meta-data, no visible effect.
                        ReadContentPropertyRecord();
                        keepOnReading = true;
                        break;

                    // The following records are publically exposed
                    case BamlRecordType.DocumentStart:
                        ReadDocumentStartRecord();
                        break;

                    case BamlRecordType.DocumentEnd:
                        ReadDocumentEndRecord();
                        break;

                    case BamlRecordType.PIMapping:
                        ReadPIMappingRecord();
                        break;

                    case BamlRecordType.LiteralContent:
                        ReadLiteralContentRecord();
                        break;

                    case BamlRecordType.ElementStart:
                    case BamlRecordType.StaticResourceStart:
                        ReadElementStartRecord();
                        break;

                    case BamlRecordType.ElementEnd:
                    case BamlRecordType.StaticResourceEnd:
                        ReadElementEndRecord();
                        break;

                    case BamlRecordType.PropertyComplexStart:
                    case BamlRecordType.PropertyArrayStart:
                    case BamlRecordType.PropertyIListStart:
                    case BamlRecordType.PropertyIDictionaryStart:
                        ReadPropertyComplexStartRecord();
                        break;

                    case BamlRecordType.PropertyComplexEnd:
                    case BamlRecordType.PropertyArrayEnd:
                    case BamlRecordType.PropertyIListEnd:
                    case BamlRecordType.PropertyIDictionaryEnd:
                        ReadPropertyComplexEndRecord();
                        break;

                    case BamlRecordType.Text:
                    case BamlRecordType.TextWithId:
                    case BamlRecordType.TextWithConverter:
                        ReadTextRecord();
                        break;

                    case BamlRecordType.DeferableContentStart:
                        ReadDeferableContentRecord();
                        keepOnReading = true;
                        break;

                    case BamlRecordType.ConstructorParametersStart:
                        ReadConstructorStart();
                        break;

                    case BamlRecordType.ConstructorParametersEnd:
                        ReadConstructorEnd();
                        break;

                    case BamlRecordType.ConnectionId:
                        ReadConnectionIdRecord();
                        break;

                    case BamlRecordType.StaticResourceId:
                        ReadStaticResourceId();
                        keepOnReading = true;
                        break;

                    default:
                        // Can't have any other type of record at this point.
                        throw new InvalidOperationException(SR.Get(SRID.ParserUnknownBaml,
                                         ((int)_currentBamlRecord.RecordType).ToString(CultureInfo.CurrentCulture)));
                }

            }

        }
        // Token: 0x06006EB5 RID: 28341 RVA: 0x001FCDA0 File Offset: 0x001FAFA0
        internal BamlLocalizableResource BuildFromNode(BamlLocalizableResourceKey key, BamlTreeNode node)
        {
            if (node.Formatted)
            {
                return(null);
            }
            BamlLocalizableResource bamlLocalizableResource = null;
            LocalizabilityAttribute localizabilityAttribute = null;
            BamlStartElementNode    node2 = null;
            string       localName        = null;
            BamlNodeType nodeType         = node.NodeType;

            if (nodeType != BamlNodeType.StartElement)
            {
                if (nodeType != BamlNodeType.Property)
                {
                    if (nodeType != BamlNodeType.LiteralContent)
                    {
                        Invariant.Assert(false);
                    }
                    else
                    {
                        string text;
                        this.GetLocalizabilityForElementNode((BamlStartElementNode)node.Parent, out localizabilityAttribute, out text);
                        node2     = (BamlStartElementNode)node.Parent;
                        localName = "$Content";
                    }
                }
                else
                {
                    BamlStartComplexPropertyNode bamlStartComplexPropertyNode = (BamlStartComplexPropertyNode)node;
                    if (LocComments.IsLocCommentsProperty(bamlStartComplexPropertyNode.OwnerTypeFullName, bamlStartComplexPropertyNode.PropertyName) || LocComments.IsLocLocalizabilityProperty(bamlStartComplexPropertyNode.OwnerTypeFullName, bamlStartComplexPropertyNode.PropertyName))
                    {
                        return(null);
                    }
                    this.GetLocalizabilityForPropertyNode(bamlStartComplexPropertyNode, out localizabilityAttribute);
                    localName = bamlStartComplexPropertyNode.PropertyName;
                    node2     = (BamlStartElementNode)node.Parent;
                }
            }
            else
            {
                node2 = (BamlStartElementNode)node;
                string text;
                this.GetLocalizabilityForElementNode(node2, out localizabilityAttribute, out text);
                localName = "$Content";
            }
            localizabilityAttribute = this.CombineAndPropagateInheritanceValues(node as ILocalizabilityInheritable, localizabilityAttribute);
            string content = null;

            if (localizabilityAttribute.Category != LocalizationCategory.NeverLocalize && localizabilityAttribute.Category != LocalizationCategory.Ignore && this.TryGetContent(key, node, out content))
            {
                bamlLocalizableResource            = new BamlLocalizableResource();
                bamlLocalizableResource.Readable   = (localizabilityAttribute.Readability == Readability.Readable);
                bamlLocalizableResource.Modifiable = (localizabilityAttribute.Modifiability == Modifiability.Modifiable);
                bamlLocalizableResource.Category   = localizabilityAttribute.Category;
                bamlLocalizableResource.Content    = content;
                bamlLocalizableResource.Comments   = this._resolver.GetStringComment(node2, localName);
            }
            return(bamlLocalizableResource);
        }
示例#12
0
        /***************************************************************************\
        *
        * BamlReader.ReadTextRecord
        *
        * Read record containing text content that goes between the start and end
        * tags of an object.
        *
        \***************************************************************************/

        private void ReadTextRecord()
        {
            ClearProperties();

            BamlTextWithIdRecord textWithIdRecord = _currentBamlRecord as BamlTextWithIdRecord;
            if (textWithIdRecord != null)
            {
                // Get the value string from the string table, and cache it in the
                // record.
                textWithIdRecord.Value = MapTable.GetStringFromStringId(
                                                textWithIdRecord.ValueId);
            }

            BamlTextWithConverterRecord textWithConverter = _currentBamlRecord as BamlTextWithConverterRecord;
            if (textWithConverter != null)
            {
                short converterTypeId = textWithConverter.ConverterTypeId;
                Type converter = MapTable.GetTypeFromId(converterTypeId);
                _typeConverterAssemblyName = converter.Assembly.FullName;
                _typeConverterName = converter.FullName;
            }

            NodeTypeInternal = BamlNodeType.Text;
            _prefix = string.Empty;
            _value = ((BamlTextRecord)_currentBamlRecord).Value;
        }
 //---------------------------
 // Constructor
 //---------------------------
 internal BamlTreeNode(BamlNodeType type)
 {
     NodeType = type;
 }
        // Token: 0x06006EAC RID: 28332 RVA: 0x001FC674 File Offset: 0x001FA874
        private static bool ApplyChangeToBamlTree(BamlLocalizableResourceKey key, BamlLocalizableResource resource, BamlTreeUpdater.BamlTreeUpdateMap treeMap)
        {
            if (resource == null || resource.Content == null || !resource.Modifiable)
            {
                return(true);
            }
            if (!treeMap.LocalizationDictionary.Contains(key) && !treeMap.IsNewBamlTreeNode(key))
            {
                return(true);
            }
            BamlTreeNode bamlTreeNode = treeMap.MapKeyToBamlTreeNode(key);

            Invariant.Assert(bamlTreeNode != null);
            BamlNodeType nodeType = bamlTreeNode.NodeType;

            if (nodeType != BamlNodeType.StartElement)
            {
                if (nodeType != BamlNodeType.Property)
                {
                    if (nodeType == BamlNodeType.LiteralContent)
                    {
                        BamlLiteralContentNode bamlLiteralContentNode = (BamlLiteralContentNode)bamlTreeNode;
                        bamlLiteralContentNode.Content = BamlResourceContentUtil.UnescapeString(resource.Content);
                        if (bamlLiteralContentNode.Parent == null)
                        {
                            BamlTreeNode bamlTreeNode2 = treeMap.MapUidToBamlTreeElementNode(key.Uid);
                            if (bamlTreeNode2 == null)
                            {
                                return(false);
                            }
                            bamlTreeNode2.AddChild(bamlLiteralContentNode);
                        }
                    }
                }
                else
                {
                    BamlPropertyNode bamlPropertyNode = (BamlPropertyNode)bamlTreeNode;
                    bamlPropertyNode.Value = BamlResourceContentUtil.UnescapeString(resource.Content);
                    if (bamlPropertyNode.Parent == null)
                    {
                        BamlStartElementNode bamlStartElementNode = treeMap.MapUidToBamlTreeElementNode(key.Uid);
                        if (bamlStartElementNode == null)
                        {
                            return(false);
                        }
                        bamlStartElementNode.InsertProperty(bamlTreeNode);
                    }
                }
            }
            else
            {
                string b = null;
                if (treeMap.LocalizationDictionary.Contains(key))
                {
                    b = treeMap.LocalizationDictionary[key].Content;
                }
                if (resource.Content != b)
                {
                    BamlTreeUpdater.ReArrangeChildren(key, bamlTreeNode, resource.Content, treeMap);
                }
            }
            return(true);
        }
        // Token: 0x06006EAE RID: 28334 RVA: 0x001FC7C0 File Offset: 0x001FA9C0
        private static void MergeChildrenList(BamlLocalizableResourceKey key, BamlTreeUpdater.BamlTreeUpdateMap treeMap, BamlTreeNode parent, IList <BamlTreeNode> newChildren)
        {
            if (newChildren == null)
            {
                return;
            }
            List <BamlTreeNode> children = parent.Children;
            int           i             = 0;
            StringBuilder stringBuilder = new StringBuilder();

            if (children != null)
            {
                Hashtable hashtable = new Hashtable(newChildren.Count);
                foreach (BamlTreeNode bamlTreeNode in newChildren)
                {
                    if (bamlTreeNode.NodeType == BamlNodeType.StartElement)
                    {
                        BamlStartElementNode bamlStartElementNode = (BamlStartElementNode)bamlTreeNode;
                        if (bamlStartElementNode.Uid != null)
                        {
                            if (hashtable.ContainsKey(bamlStartElementNode.Uid))
                            {
                                treeMap.Resolver.RaiseErrorNotifyEvent(new BamlLocalizerErrorNotifyEventArgs(key, BamlLocalizerError.DuplicateElement));
                                return;
                            }
                            hashtable[bamlStartElementNode.Uid] = null;
                        }
                    }
                }
                parent.Children = null;
                for (int j = 0; j < children.Count - 1; j++)
                {
                    BamlTreeNode bamlTreeNode2 = children[j];
                    BamlNodeType nodeType      = bamlTreeNode2.NodeType;
                    if (nodeType != BamlNodeType.StartElement)
                    {
                        if (nodeType != BamlNodeType.Text)
                        {
                            parent.AddChild(bamlTreeNode2);
                        }
                    }
                    else
                    {
                        BamlStartElementNode bamlStartElementNode2 = (BamlStartElementNode)bamlTreeNode2;
                        if (bamlStartElementNode2.Uid != null)
                        {
                            if (!hashtable.ContainsKey(bamlStartElementNode2.Uid))
                            {
                                parent.Children = children;
                                treeMap.Resolver.RaiseErrorNotifyEvent(new BamlLocalizerErrorNotifyEventArgs(key, BamlLocalizerError.MismatchedElements));
                                return;
                            }
                            hashtable.Remove(bamlStartElementNode2.Uid);
                        }
                        while (i < newChildren.Count)
                        {
                            BamlTreeNode bamlTreeNode3 = newChildren[i++];
                            Invariant.Assert(bamlTreeNode3 != null);
                            if (bamlTreeNode3.NodeType == BamlNodeType.Text)
                            {
                                stringBuilder.Append(((BamlTextNode)bamlTreeNode3).Content);
                            }
                            else
                            {
                                BamlTreeUpdater.TryFlushTextToBamlNode(parent, stringBuilder);
                                parent.AddChild(bamlTreeNode3);
                                if (bamlTreeNode3.NodeType == BamlNodeType.StartElement)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            while (i < newChildren.Count)
            {
                BamlTreeNode bamlTreeNode4 = newChildren[i];
                Invariant.Assert(bamlTreeNode4 != null);
                if (bamlTreeNode4.NodeType == BamlNodeType.Text)
                {
                    stringBuilder.Append(((BamlTextNode)bamlTreeNode4).Content);
                }
                else
                {
                    BamlTreeUpdater.TryFlushTextToBamlNode(parent, stringBuilder);
                    parent.AddChild(bamlTreeNode4);
                }
                i++;
            }
            BamlTreeUpdater.TryFlushTextToBamlNode(parent, stringBuilder);
            parent.AddChild(new BamlEndElementNode());
        }
 //---------------------------
 // Constructor
 //---------------------------
 internal BamlTreeNode(BamlNodeType type)
 {
     NodeType = type;
 }    
示例#17
0
        /***************************************************************************\
        *
        * BamlReader.ReadPropertyComplexStartRecord
        *
        * Read the start of a complex property.  This can be any type of complex
        * property, including arrays, ILists, IDictionaries, Clr properties or
        * dependency properties.
        *
        \***************************************************************************/

        private void ReadPropertyComplexStartRecord()
        {
            ClearProperties();
            _parserContext.PushScope();
            _prefixDictionary.PushScope();

            BamlNodeInfo nodeInfo = new BamlNodeInfo();

            SetCommonPropertyInfo(nodeInfo,
                      ((BamlPropertyComplexStartRecord)_currentBamlRecord).AttributeId);

            // Set instance variables to node info extracted from record.
            NodeTypeInternal = BamlNodeType.StartComplexProperty;
            _localName = nodeInfo.LocalName;
            int index = nodeInfo.Name.LastIndexOf(".", StringComparison.Ordinal);
            if (index > 0)
            {
                _ownerTypeName = nodeInfo.Name.Substring(0, index);
            }
            else
            {
                // Eg. xmlns property
                _ownerTypeName = string.Empty;
            }
            _name = nodeInfo.Name;
            _clrNamespace = nodeInfo.ClrNamespace;
            _assemblyName = nodeInfo.AssemblyName;
            _prefix = nodeInfo.Prefix;
            _xmlNamespace = nodeInfo.XmlNamespace;
            nodeInfo.RecordType = _currentBamlRecord.RecordType;


            _nodeStack.Push(nodeInfo);

            // Read the properties that may be part of the start tag
            ReadProperties();
        }
示例#18
0
        /***************************************************************************\
        *
        * BamlReader.ReadConstructorEnd
        *
        * Read a <\x:ConstructorParameters   ...   > end tag, which indicates that
        * the previous objects are to be used as constructor parameters.
        *
        \***************************************************************************/

        private void ReadConstructorEnd()
        {
            ClearProperties();

            NodeTypeInternal = BamlNodeType.EndConstructor;

            // Pop information off the node stack that tells us what element this
            // is the end of.  Check to make sure the record on the stack is for a
            // start element.
            BamlNodeInfo nodeInfo = (BamlNodeInfo)_nodeStack.Pop();
            if (nodeInfo.RecordType != BamlRecordType.ConstructorParametersStart)
            {
                throw new InvalidOperationException(SR.Get(SRID.BamlScopeError,
                                                 _currentBamlRecord.RecordType.ToString(),
                                                 BamlRecordType.ConstructorParametersEnd.ToString()));
            }

            // read properties, if any, after this end tag.
            ReadProperties();
        }
示例#19
0
        /***************************************************************************\
        *
        * BamlReader.ReadPropertyComplexEndRecord
        *
        * Read the end of a complex property.  This can be any type of complex
        * property, including arrays, ILists, IDictionaries, Clr properties or
        * dependency properties.
        *
        \***************************************************************************/

        private void ReadPropertyComplexEndRecord()
        {
            // Pop information off the node info stack that tells us what the starting
            // record was for this ending record.  Check to make sure it is the
            // correct type.  If not, throw an exception.
            BamlNodeInfo nodeInfo = (BamlNodeInfo)_nodeStack.Pop();
            BamlRecordType expectedType;
            switch (nodeInfo.RecordType)
            {
                case BamlRecordType.PropertyComplexStart:
                    expectedType = BamlRecordType.PropertyComplexEnd;
                    break;
                case BamlRecordType.PropertyArrayStart:
                    expectedType = BamlRecordType.PropertyArrayEnd;
                    break;
                case BamlRecordType.PropertyIListStart:
                    expectedType = BamlRecordType.PropertyIListEnd;
                    break;
                case BamlRecordType.PropertyIDictionaryStart:
                    expectedType = BamlRecordType.PropertyIDictionaryEnd;
                    break;
                default:
                    expectedType = BamlRecordType.Unknown;
                    break;
            }

            if (_currentBamlRecord.RecordType != expectedType)
            {
                throw new InvalidOperationException(SR.Get(SRID.BamlScopeError,
                                          _currentBamlRecord.RecordType.ToString(),
                                          expectedType.ToString()));
            }

            ClearProperties();
            NodeTypeInternal = BamlNodeType.EndComplexProperty;
            _name = nodeInfo.Name;
            _localName = nodeInfo.LocalName;
            int index = nodeInfo.Name.LastIndexOf(".", StringComparison.Ordinal);
            if (index > 0)
            {
                _ownerTypeName = nodeInfo.Name.Substring(0, index);
            }
            else
            {
                // Eg. xmlns property
                _ownerTypeName = string.Empty;
            }
            _assemblyName = nodeInfo.AssemblyName;
            _prefix = nodeInfo.Prefix;
            _xmlNamespace = nodeInfo.XmlNamespace;
            _clrNamespace = nodeInfo.ClrNamespace;
            _parserContext.PopScope();
            _prefixDictionary.PopScope();

            ReadProperties();
        }
        // Token: 0x06006EBA RID: 28346 RVA: 0x001FD2AC File Offset: 0x001FB4AC
        private LocalizabilityAttribute CombineAndPropagateInheritanceValues(ILocalizabilityInheritable node, LocalizabilityAttribute localizabilityFromSource)
        {
            if (node == null)
            {
                return(localizabilityFromSource);
            }
            if (node.InheritableAttribute != null)
            {
                if (node.IsIgnored)
                {
                    return(this.LocalizabilityIgnore);
                }
                return(node.InheritableAttribute);
            }
            else
            {
                if (localizabilityFromSource.Category != LocalizationCategory.Ignore && localizabilityFromSource.Category != LocalizationCategory.Inherit && localizabilityFromSource.Readability != Readability.Inherit && localizabilityFromSource.Modifiability != Modifiability.Inherit)
                {
                    node.InheritableAttribute = localizabilityFromSource;
                    return(node.InheritableAttribute);
                }
                ILocalizabilityInheritable localizabilityAncestor = node.LocalizabilityAncestor;
                LocalizabilityAttribute    inheritableAttribute   = localizabilityAncestor.InheritableAttribute;
                if (inheritableAttribute == null)
                {
                    BamlStartElementNode bamlStartElementNode = localizabilityAncestor as BamlStartElementNode;
                    if (bamlStartElementNode != null)
                    {
                        string text;
                        this.GetLocalizabilityForElementNode(bamlStartElementNode, out inheritableAttribute, out text);
                    }
                    else
                    {
                        BamlStartComplexPropertyNode node2 = localizabilityAncestor as BamlStartComplexPropertyNode;
                        this.GetLocalizabilityForPropertyNode(node2, out inheritableAttribute);
                    }
                    this.CombineAndPropagateInheritanceValues(localizabilityAncestor, inheritableAttribute);
                    inheritableAttribute = localizabilityAncestor.InheritableAttribute;
                }
                if (localizabilityFromSource.Category == LocalizationCategory.Ignore)
                {
                    node.InheritableAttribute = inheritableAttribute;
                    node.IsIgnored            = true;
                    return(this.LocalizabilityIgnore);
                }
                BamlTreeNode bamlTreeNode = (BamlTreeNode)node;
                BamlNodeType nodeType     = bamlTreeNode.NodeType;
                if (nodeType <= BamlNodeType.Property)
                {
                    if (nodeType != BamlNodeType.StartElement)
                    {
                        if (nodeType != BamlNodeType.Property)
                        {
                            goto IL_174;
                        }
                        goto IL_127;
                    }
                }
                else
                {
                    if (nodeType == BamlNodeType.StartComplexProperty)
                    {
                        goto IL_127;
                    }
                    if (nodeType != BamlNodeType.LiteralContent)
                    {
                        goto IL_174;
                    }
                }
                if (localizabilityFromSource.Category == LocalizationCategory.Inherit && localizabilityFromSource.Readability == Readability.Inherit && localizabilityFromSource.Modifiability == Modifiability.Inherit)
                {
                    node.InheritableAttribute = inheritableAttribute;
                    goto IL_174;
                }
                node.InheritableAttribute = this.CreateInheritedLocalizability(localizabilityFromSource, inheritableAttribute);
                goto IL_174;
IL_127:
                ILocalizabilityInheritable localizabilityInheritable = (ILocalizabilityInheritable)bamlTreeNode.Parent;
                LocalizabilityAttribute inheritable = this.CombineMinimumLocalizability(inheritableAttribute, localizabilityInheritable.InheritableAttribute);
                node.InheritableAttribute = this.CreateInheritedLocalizability(localizabilityFromSource, inheritable);
                if (localizabilityInheritable.IsIgnored && localizabilityFromSource.Category == LocalizationCategory.Inherit)
                {
                    node.IsIgnored = true;
                    return(this.LocalizabilityIgnore);
                }
IL_174:
                return(node.InheritableAttribute);
            }
        }
示例#21
0
        /***************************************************************************\
        *
        * BamlReader.ReadConstructorStart
        *
        * Read a <x:ConstructorParameters   ...   > start tag, which indicates that
        * the following objects are to be used as constructor parameters.
        *
        \***************************************************************************/

        private void ReadConstructorStart()
        {
            ClearProperties();

            NodeTypeInternal = BamlNodeType.StartConstructor;

            // Push information on the node stack to indicate we have a start array
            BamlNodeInfo nodeInfo = new BamlNodeInfo();
            nodeInfo.RecordType = BamlRecordType.ConstructorParametersStart;

            _nodeStack.Push(nodeInfo);
        }
示例#22
0
        // Token: 0x06006E10 RID: 28176 RVA: 0x001FA87C File Offset: 0x001F8A7C
        private BamlTree LoadBamlImp(Stream bamlSteam)
        {
            this._reader = new BamlReader(bamlSteam);
            this._reader.Read();
            if (this._reader.NodeType != BamlNodeType.StartDocument)
            {
                throw new XamlParseException(SR.Get("InvalidStartOfBaml"));
            }
            this._root = new BamlStartDocumentNode();
            this.PushNodeToStack(this._root);
            Hashtable hashtable = new Hashtable(8);

IL_5C8:
            while (this._bamlTreeStack.Count > 0 && this._reader.Read())
            {
                switch (this._reader.NodeType)
                {
                case BamlNodeType.EndDocument:
                {
                    BamlTreeNode node = new BamlEndDocumentNode();
                    this.AddChildToCurrentParent(node);
                    this.PopStack();
                    break;
                }

                case BamlNodeType.ConnectionId:
                case BamlNodeType.Property:
                case BamlNodeType.ContentProperty:
                case BamlNodeType.XmlnsProperty:
                case BamlNodeType.IncludeReference:
                case BamlNodeType.DefAttribute:
                case BamlNodeType.PresentationOptionsAttribute:
                    goto IL_2DF;

                case BamlNodeType.StartElement:
                {
                    BamlTreeNode node2 = new BamlStartElementNode(this._reader.AssemblyName, this._reader.Name, this._reader.IsInjected, this._reader.CreateUsingTypeConverter);
                    this.PushNodeToStack(node2);
                    break;
                }

                case BamlNodeType.EndElement:
                {
                    BamlTreeNode node3 = new BamlEndElementNode();
                    this.AddChildToCurrentParent(node3);
                    this.PopStack();
                    break;
                }

                case BamlNodeType.StartComplexProperty:
                {
                    BamlStartComplexPropertyNode bamlStartComplexPropertyNode = new BamlStartComplexPropertyNode(this._reader.AssemblyName, this._reader.Name.Substring(0, this._reader.Name.LastIndexOf('.')), this._reader.LocalName);
                    bamlStartComplexPropertyNode.LocalizabilityAncestor = this.PeekPropertyStack(bamlStartComplexPropertyNode.PropertyName);
                    this.PushPropertyToStack(bamlStartComplexPropertyNode.PropertyName, bamlStartComplexPropertyNode);
                    this.PushNodeToStack(bamlStartComplexPropertyNode);
                    break;
                }

                case BamlNodeType.EndComplexProperty:
                {
                    BamlTreeNode node4 = new BamlEndComplexPropertyNode();
                    this.AddChildToCurrentParent(node4);
                    this.PopStack();
                    break;
                }

                case BamlNodeType.LiteralContent:
                {
                    BamlTreeNode node5 = new BamlLiteralContentNode(this._reader.Value);
                    this.AddChildToCurrentParent(node5);
                    break;
                }

                case BamlNodeType.Text:
                {
                    BamlTreeNode node6 = new BamlTextNode(this._reader.Value, this._reader.TypeConverterAssemblyName, this._reader.TypeConverterName);
                    this.AddChildToCurrentParent(node6);
                    break;
                }

                case BamlNodeType.RoutedEvent:
                {
                    BamlTreeNode node7 = new BamlRoutedEventNode(this._reader.AssemblyName, this._reader.Name.Substring(0, this._reader.Name.LastIndexOf('.')), this._reader.LocalName, this._reader.Value);
                    this.AddChildToCurrentParent(node7);
                    break;
                }

                case BamlNodeType.Event:
                {
                    BamlTreeNode node8 = new BamlEventNode(this._reader.Name, this._reader.Value);
                    this.AddChildToCurrentParent(node8);
                    break;
                }

                case BamlNodeType.PIMapping:
                {
                    BamlTreeNode node9 = new BamlPIMappingNode(this._reader.XmlNamespace, this._reader.ClrNamespace, this._reader.AssemblyName);
                    this.AddChildToCurrentParent(node9);
                    break;
                }

                case BamlNodeType.StartConstructor:
                {
                    BamlTreeNode node10 = new BamlStartConstructorNode();
                    this.AddChildToCurrentParent(node10);
                    break;
                }

                case BamlNodeType.EndConstructor:
                {
                    BamlTreeNode node11 = new BamlEndConstructorNode();
                    this.AddChildToCurrentParent(node11);
                    break;
                }

                default:
                    goto IL_2DF;
                }
                if (this._reader.HasProperties)
                {
                    hashtable.Clear();
                    this._reader.MoveToFirstProperty();
                    for (;;)
                    {
                        BamlNodeType nodeType = this._reader.NodeType;
                        switch (nodeType)
                        {
                        case BamlNodeType.ConnectionId:
                        {
                            BamlTreeNode node12 = new BamlConnectionIdNode(this._reader.ConnectionId);
                            this.AddChildToCurrentParent(node12);
                            break;
                        }

                        case BamlNodeType.StartElement:
                        case BamlNodeType.EndElement:
                            goto IL_58F;

                        case BamlNodeType.Property:
                        {
                            BamlPropertyNode bamlPropertyNode = new BamlPropertyNode(this._reader.AssemblyName, this._reader.Name.Substring(0, this._reader.Name.LastIndexOf('.')), this._reader.LocalName, this._reader.Value, this._reader.AttributeUsage);
                            bamlPropertyNode.LocalizabilityAncestor = this.PeekPropertyStack(bamlPropertyNode.PropertyName);
                            this.PushPropertyToStack(bamlPropertyNode.PropertyName, bamlPropertyNode);
                            this.AddChildToCurrentParent(bamlPropertyNode);
                            if (hashtable.Contains(this._reader.Name))
                            {
                                object obj = hashtable[this._reader.Name];
                                int    num = 2;
                                if (obj is BamlPropertyNode)
                                {
                                    ((BamlPropertyNode)obj).Index = 1;
                                }
                                else
                                {
                                    num = (int)obj;
                                }
                                bamlPropertyNode.Index       = num;
                                hashtable[this._reader.Name] = num + 1;
                            }
                            else
                            {
                                hashtable[this._reader.Name] = bamlPropertyNode;
                            }
                            break;
                        }

                        case BamlNodeType.ContentProperty:
                        {
                            BamlTreeNode node13 = new BamlContentPropertyNode(this._reader.AssemblyName, this._reader.Name.Substring(0, this._reader.Name.LastIndexOf('.')), this._reader.LocalName);
                            this.AddChildToCurrentParent(node13);
                            break;
                        }

                        case BamlNodeType.XmlnsProperty:
                        {
                            BamlTreeNode node14 = new BamlXmlnsPropertyNode(this._reader.LocalName, this._reader.Value);
                            this.AddChildToCurrentParent(node14);
                            break;
                        }

                        default:
                            if (nodeType != BamlNodeType.DefAttribute)
                            {
                                if (nodeType != BamlNodeType.PresentationOptionsAttribute)
                                {
                                    goto Block_6;
                                }
                                BamlTreeNode node15 = new BamlPresentationOptionsAttributeNode(this._reader.Name, this._reader.Value);
                                this.AddChildToCurrentParent(node15);
                            }
                            else
                            {
                                if (this._reader.Name == "Uid")
                                {
                                    ((BamlStartElementNode)this._currentParent).Uid = this._reader.Value;
                                }
                                BamlTreeNode node16 = new BamlDefAttributeNode(this._reader.Name, this._reader.Value);
                                this.AddChildToCurrentParent(node16);
                            }
                            break;
                        }
                        if (!this._reader.MoveToNextProperty())
                        {
                            goto IL_5C8;
                        }
                    }
Block_6:
IL_58F:
                    throw new XamlParseException(SR.Get("UnRecognizedBamlNodeType", new object[]
                    {
                        this._reader.NodeType
                    }));
                }
                continue;
IL_2DF:
                throw new XamlParseException(SR.Get("UnRecognizedBamlNodeType", new object[]
                {
                    this._reader.NodeType
                }));
            }
            if (this._reader.Read() || this._bamlTreeStack.Count > 0)
            {
                throw new XamlParseException(SR.Get("InvalidEndOfBaml"));
            }
            return(new BamlTree(this._root, this._nodeCount));
        }
示例#23
0
        /// <summary>
        /// Move to the next property for this element or object.
        /// Return true if there is a next property; false if there are no more properties.
        /// </summary>
        public bool MoveToNextProperty()
        {
            if (_propertiesIndex < _properties.Count - 1)
            {
                _propertiesIndex++;
                object obj = _properties[_propertiesIndex];

                BamlPropertyInfo info = obj as BamlPropertyInfo;
                if (info != null)
                {
                    _name = info.Name;
                    _localName = info.LocalName;
                    int index = info.Name.LastIndexOf(".", StringComparison.Ordinal);
                    if (index > 0)
                    {
                        _ownerTypeName = info.Name.Substring(0, index);
                    }
                    else
                    {
                        // Eg. xmlns property
                        _ownerTypeName = string.Empty;
                    }
                    _value = info.Value;
                    _assemblyName = info.AssemblyName;
                    _prefix = info.Prefix;
                    _xmlNamespace = info.XmlNamespace;
                    _clrNamespace = info.ClrNamespace;
                    _connectionId = 0;
                    _contentPropertyName = string.Empty;
                    _attributeUsage = info.AttributeUsage;

                    // There are several node types for properties, but for now the only one that
                    // doesn't map to BamlNodeType.Property is xml namespace declarations.
                    if (info.RecordType == BamlRecordType.XmlnsProperty)
                    {
                        NodeTypeInternal = BamlNodeType.XmlnsProperty;
                    }
                    else if (info.RecordType == BamlRecordType.DefAttribute)
                    {
                        NodeTypeInternal = BamlNodeType.DefAttribute;
                    }
                    else if (info.RecordType == BamlRecordType.PresentationOptionsAttribute)
                    {
                        NodeTypeInternal = BamlNodeType.PresentationOptionsAttribute;
                    }
                    else
                    {
                        NodeTypeInternal = BamlNodeType.Property;
                    }
                    return true;
                }

                BamlContentPropertyInfo cpInfo = obj as BamlContentPropertyInfo;
                if(null != cpInfo)
                {
                    _contentPropertyName = cpInfo.LocalName;
                    _connectionId = 0;
                    _prefix = string.Empty;
                    _name = cpInfo.Name;
                    int index = cpInfo.Name.LastIndexOf(".", StringComparison.Ordinal);
                    if (index > 0)
                    {
                        _ownerTypeName = cpInfo.Name.Substring(0, index);
                    }

                    _localName = cpInfo.LocalName;
                    _ownerTypeName = string.Empty;
                    _assemblyName = cpInfo.AssemblyName;
                    _xmlNamespace = string.Empty;
                    _clrNamespace = string.Empty;
                    _attributeUsage = BamlAttributeUsage.Default;
                    _value = cpInfo.LocalName;
                    NodeTypeInternal = BamlNodeType.ContentProperty;
                    return true;
                }
                // Otherwise it must be a ConnectionId.
                // Is there something we can Assert on for that?
                _connectionId = (Int32)obj;
                _contentPropertyName = string.Empty;
                _prefix = string.Empty;
                _name = string.Empty;
                _localName = string.Empty;
                _ownerTypeName = string.Empty;
                _assemblyName = string.Empty;
                _xmlNamespace = string.Empty;
                _clrNamespace = string.Empty;
                _attributeUsage = BamlAttributeUsage.Default;
                _value = _connectionId.ToString(CultureInfo.CurrentCulture);
                NodeTypeInternal = BamlNodeType.ConnectionId;
                return true;
            }
            else
            {
                return false;
            }
        }
示例#24
0
        /***************************************************************************\
        *
        * BamlReader.ReadDocumentStartRecord
        *
        * Read the start of the document record.  This should contain some
        * version information.
        *
        \***************************************************************************/

        private void ReadDocumentStartRecord()
        {
            ClearProperties();
            NodeTypeInternal = BamlNodeType.StartDocument;

            BamlDocumentStartRecord documentStartRecord = (BamlDocumentStartRecord)_currentBamlRecord;
            _parserContext.IsDebugBamlStream = documentStartRecord.DebugBaml;

            // Push information on the node stack to indicate we have a start document
            BamlNodeInfo nodeInfo = new BamlNodeInfo();
            nodeInfo.RecordType = BamlRecordType.DocumentStart;
            _nodeStack.Push(nodeInfo);
        }
 public T FindLastChild <T>(BamlNodeType type, bool throwIfMissing = false)
     where T : BamlNode
 {
     return((T)FindLastChild(n => n.NodeType == type, throwIfMissing));
 }
示例#26
0
        /***************************************************************************\
        *
        * BamlReader.ReadDocumentEndRecord
        *
        * Read the end of the document record.  This is used to flag that the end
        * of the file has been reached.
        *
        \***************************************************************************/

        private void ReadDocumentEndRecord()
        {
            // Pop information off the node stack to ensure we have matched all the
            // start and end nodes and have nothing left but the start document node.
            BamlNodeInfo nodeInfo = (BamlNodeInfo)_nodeStack.Pop();
            if (nodeInfo.RecordType != BamlRecordType.DocumentStart)
            {
                throw new InvalidOperationException(SR.Get(SRID.BamlScopeError,
                                                    nodeInfo.RecordType.ToString(),
                                                    "DocumentEnd"));
            }

            ClearProperties();
            NodeTypeInternal = BamlNodeType.EndDocument;
        }