コード例 #1
0
 private void PushScope(int elementDepth)
 {
     if (this._compatibilityScope.Depth < elementDepth)
     {
         this._compatibilityScope = new CompatibilityScope(this._compatibilityScope, elementDepth, this);
     }
 }
コード例 #2
0
 public XmlCompatibilityReader(XmlReader baseReader) : base(baseReader)
 {
     this._namespaceMap       = new Dictionary <string, string>();
     this._elementHandler     = new Dictionary <string, HandleElementCallback>();
     this._attributeHandler   = new Dictionary <string, HandleAttributeCallback>();
     this._compatibilityScope = new CompatibilityScope(null, -1, this);
     foreach (string str in _predefinedNamespaces)
     {
         this.AddKnownNamespace(str);
         this._namespaceMap[str] = str;
         base.Reader.NameTable.Add(str);
     }
     this._elementHandler.Add(this.AlternateContent, new HandleElementCallback(this.HandleAlternateContent));
     this._elementHandler.Add(this.Choice, new HandleElementCallback(this.HandleChoice));
     this._elementHandler.Add(this.Fallback, new HandleElementCallback(this.HandleFallback));
     this._attributeHandler.Add(this.Ignorable, new HandleAttributeCallback(this.HandleIgnorable));
     this._attributeHandler.Add(this.MustUnderstand, new HandleAttributeCallback(this.HandleMustUnderstand));
     this._attributeHandler.Add(this.ProcessContent, new HandleAttributeCallback(this.HandleProcessContent));
     this._attributeHandler.Add(this.PreserveElements, new HandleAttributeCallback(this.HandlePreserveElements));
     this._attributeHandler.Add(this.PreserveAttributes, new HandleAttributeCallback(this.HandlePreserveAttributes));
 }
コード例 #3
0
        public XmlCompatibilityReader(XmlReader baseReader)
            : base(baseReader)
        {
            _compatibilityScope = new CompatibilityScope(null, -1, this);

            foreach (string xmlNamespace in _predefinedNamespaces)
            {
                AddKnownNamespace(xmlNamespace);
                _namespaceMap[xmlNamespace] = xmlNamespace;
                Reader.NameTable.Add(xmlNamespace);
            }

            _elementHandler.Add(AlternateContent, new HandleElementCallback(HandleAlternateContent));
            _elementHandler.Add(Choice, new HandleElementCallback(HandleChoice));
            _elementHandler.Add(Fallback, new HandleElementCallback(HandleFallback));

            _attributeHandler.Add(Ignorable, new HandleAttributeCallback(HandleIgnorable));
            _attributeHandler.Add(MustUnderstand, new HandleAttributeCallback(HandleMustUnderstand));
            _attributeHandler.Add(ProcessContent, new HandleAttributeCallback(HandleProcessContent));
            _attributeHandler.Add(PreserveElements, new HandleAttributeCallback(HandlePreserveElements));
            _attributeHandler.Add(PreserveAttributes, new HandleAttributeCallback(HandlePreserveAttributes));
        }
コード例 #4
0
 public CompatibilityScope(CompatibilityScope previous, int depth, XmlCompatibilityReader reader)
 {
     _previous = previous;
     _depth = depth;
     _reader = reader;
 }
コード例 #5
0
 /// <summary>
 /// pushes a new scope onto the stack with a depth passed as an arg.
 /// PushScope does not push a scope if the top scope on the stack is not a lower depth.
 /// </summary>
 /// <param name="elementDepth">
 /// the depth of the Reader at the element currently being processed
 /// </param>
 private void PushScope(int elementDepth)
 {
     if (_compatibilityScope.Depth < elementDepth)
     {
         // if the current element has already pushed a scope, then don't push another one
         _compatibilityScope = new CompatibilityScope(_compatibilityScope, elementDepth, this);
     }
 }
コード例 #6
0
 private void PopScope()
 {
     this._compatibilityScope = this._compatibilityScope.Previous;
 }
コード例 #7
0
        private void HandleChoice(int elementDepth, ref bool more)
        {
            if (!this.Scope.InAlternateContent)
            {
                this.Error(System.Xaml.SR.Get("XCRChoiceOnlyInAC"), new object[0]);
            }
            if (this.Scope.FallbackSeen)
            {
                this.Error(System.Xaml.SR.Get("XCRChoiceAfterFallback"), new object[0]);
            }
            string attribute = base.Reader.GetAttribute(this.Requires);

            if (attribute == null)
            {
                this.Error(System.Xaml.SR.Get("XCRRequiresAttribNotFound"), new object[0]);
            }
            if (string.IsNullOrEmpty(attribute))
            {
                this.Error(System.Xaml.SR.Get("XCRInvalidRequiresAttribute"), new object[0]);
            }
            CompatibilityScope scope = this.Scope;

            this.ScanForCompatibility(elementDepth);
            if (this.AttributeCount != 1)
            {
                this.MoveToFirstAttribute();
                if (base.Reader.LocalName == this.Requires)
                {
                    this.MoveToNextAttribute();
                }
                string localName = base.Reader.LocalName;
                this.MoveToElement();
                this.Error(System.Xaml.SR.Get("XCRInvalidAttribInElement"), new object[] { localName, this.Choice });
            }
            if (scope.ChoiceTaken)
            {
                this.ScanForEndCompatibility(elementDepth);
                base.Reader.Skip();
            }
            else
            {
                scope.ChoiceSeen = true;
                bool flag  = true;
                bool flag2 = false;
                foreach (string str3 in this.PrefixesToNamespaces(attribute))
                {
                    flag2 = true;
                    if (!this.IsNamespaceKnown(str3))
                    {
                        flag = false;
                        break;
                    }
                }
                if (!flag2)
                {
                    this.Error(System.Xaml.SR.Get("XCRInvalidRequiresAttribute"), new object[0]);
                }
                if (flag)
                {
                    scope.ChoiceTaken = true;
                    this.PushScope(elementDepth);
                    this._depthOffset++;
                    more = base.Reader.Read();
                }
                else
                {
                    this.ScanForEndCompatibility(elementDepth);
                    base.Reader.Skip();
                }
            }
        }