コード例 #1
0
ファイル: ExtensionDataReader.cs プロジェクト: dotnet/corefx
 internal void SetDataNode(IDataNode dataNode, string name, string ns)
 {
     SetNextElement(dataNode, name, ns, null);
     _element = _nextElement;
     _nextElement = null;
     SetElement();
 }
 private bool CheckIfNodeHandled(IDataNode node)
 {
     bool flag = false;
     if (node.Id != Globals.NewObjectId)
     {
         flag = this.cache[node] != null;
         if (flag)
         {
             if (this.nextElement == null)
             {
                 this.nextElement = this.GetNextElement();
             }
             this.nextElement.attributeCount = 0;
             this.nextElement.AddAttribute("z", "http://schemas.microsoft.com/2003/10/Serialization/", "Ref", node.Id.ToString(NumberFormatInfo.InvariantInfo));
             this.nextElement.AddAttribute("i", "http://www.w3.org/2001/XMLSchema-instance", "nil", "true");
             this.internalNodeType = ExtensionDataNodeType.ReferencedElement;
             return flag;
         }
         this.cache.Add(node, node);
     }
     return flag;
 }
コード例 #3
0
 internal void Reset()
 {
     this.localName = null;
     this.ns = null;
     this.prefix = null;
     this.value = null;
     this.attributeCount = 0;
     this.attributeIndex = -1;
     this.depth = 0;
     this.element = null;
     this.nextElement = null;
     this.elements = null;
     this.deserializedDataNodes = null;
 }
コード例 #4
0
ファイル: ExtensionDataReader.cs プロジェクト: dotnet/corefx
 internal void Reset()
 {
     _localName = null;
     _ns = null;
     _prefix = null;
     _value = null;
     _attributeCount = 0;
     _attributeIndex = -1;
     _depth = 0;
     _element = null;
     _nextElement = null;
     _elements = null;
     _deserializedDataNodes = null;
 }
コード例 #5
0
ファイル: ExtensionDataReader.cs プロジェクト: dotnet/corefx
 private void GrowElementsIfNeeded()
 {
     if (_elements == null)
         _elements = new ElementData[8];
     else if (_elements.Length == _depth)
     {
         ElementData[] newElements = new ElementData[_elements.Length * 2];
         Array.Copy(_elements, 0, newElements, 0, _elements.Length);
         _elements = newElements;
     }
 }
コード例 #6
0
 public override void GetData(ElementData element)
 {
     base.GetData(element);
     element.AddAttribute("z", "http://schemas.microsoft.com/2003/10/Serialization/", "Size", this.Size.ToString(NumberFormatInfo.InvariantInfo));
 }
コード例 #7
0
        void PopElement()
        {
            this.prefix = element.prefix;
            this.localName = element.localName;
            this.ns = element.ns;

            if (depth == 0)
                return;

            this.depth--;

            if (elements != null)
            {
                this.element = elements[depth];
            }
        }
コード例 #8
0
        void MoveNextInXml(XmlDataNode dataNode)
        {
            if (IsXmlDataNode)
            {
                xmlNodeReader.Read();
                if (xmlNodeReader.Depth == 0)
                {
                    this.internalNodeType = ExtensionDataNodeType.EndElement;
                    xmlNodeReader = null;
                }
            }
            else
            {
                internalNodeType = ExtensionDataNodeType.Xml;
                if (element == null)
                    element = nextElement;
                else
                    PushElement();

                XmlNode wrapperElement = XmlObjectSerializerReadContext.CreateWrapperXmlElement(dataNode.OwnerDocument,
                    dataNode.XmlAttributes, dataNode.XmlChildNodes, element.prefix, element.localName, element.ns);
                for (int i = 0; i < element.attributeCount; i++)
                {
                    AttributeData a = element.attributes[i];
                    XmlAttribute xmlAttr = dataNode.OwnerDocument.CreateAttribute(a.prefix, a.localName, a.ns);
                    xmlAttr.Value = a.value;
                    wrapperElement.Attributes.Append(xmlAttr);
                }
                xmlNodeReader = new XmlNodeReader(wrapperElement);
                xmlNodeReader.Read();
            }
        }
 private void SetNextElement(IDataNode node, string name, string ns, string prefix)
 {
     this.internalNodeType = ExtensionDataNodeType.Element;
     this.nextElement = this.GetNextElement();
     this.nextElement.localName = name;
     this.nextElement.ns = ns;
     this.nextElement.prefix = prefix;
     if (node == null)
     {
         this.nextElement.attributeCount = 0;
         this.nextElement.AddAttribute("i", "http://www.w3.org/2001/XMLSchema-instance", "nil", "true");
         this.internalNodeType = ExtensionDataNodeType.NullElement;
     }
     else if (!this.CheckIfNodeHandled(node))
     {
         this.AddDeserializedDataNode(node);
         node.GetData(this.nextElement);
         if (node is XmlDataNode)
         {
             this.MoveNextInXml((XmlDataNode) node);
         }
     }
 }
 internal void SetDataNode(IDataNode dataNode, string name, string ns)
 {
     this.SetNextElement(dataNode, name, ns, null);
     this.element = this.nextElement;
     this.nextElement = null;
     this.SetElement();
 }
 private void PushElement()
 {
     this.GrowElementsIfNeeded();
     this.elements[this.depth++] = this.element;
     if (this.nextElement == null)
     {
         this.element = this.GetNextElement();
     }
     else
     {
         this.element = this.nextElement;
         this.nextElement = null;
     }
 }
 private void PopElement()
 {
     this.prefix = this.element.prefix;
     this.localName = this.element.localName;
     this.ns = this.element.ns;
     if (this.depth != 0)
     {
         this.depth--;
         if (this.elements != null)
         {
             this.element = this.elements[this.depth];
         }
     }
 }
 private void MoveNextInXml(XmlDataNode dataNode)
 {
     if (this.IsXmlDataNode)
     {
         this.xmlNodeReader.Read();
         if (this.xmlNodeReader.Depth == 0)
         {
             this.internalNodeType = ExtensionDataNodeType.EndElement;
             this.xmlNodeReader = null;
         }
     }
     else
     {
         this.internalNodeType = ExtensionDataNodeType.Xml;
         if (this.element == null)
         {
             this.element = this.nextElement;
         }
         else
         {
             this.PushElement();
         }
         System.Xml.XmlNode node = XmlObjectSerializerReadContext.CreateWrapperXmlElement(dataNode.OwnerDocument, dataNode.XmlAttributes, dataNode.XmlChildNodes, this.element.prefix, this.element.localName, this.element.ns);
         for (int i = 0; i < this.element.attributeCount; i++)
         {
             AttributeData data = this.element.attributes[i];
             System.Xml.XmlAttribute attribute = dataNode.OwnerDocument.CreateAttribute(data.prefix, data.localName, data.ns);
             attribute.Value = data.value;
             node.Attributes.Append(attribute);
         }
         this.xmlNodeReader = new XmlNodeReader(node);
         this.xmlNodeReader.Read();
     }
 }
 private void GrowElementsIfNeeded()
 {
     if (this.elements == null)
     {
         this.elements = new ElementData[8];
     }
     else if (this.elements.Length == this.depth)
     {
         ElementData[] destinationArray = new ElementData[this.elements.Length * 2];
         Array.Copy(this.elements, 0, destinationArray, 0, this.elements.Length);
         this.elements = destinationArray;
     }
 }
コード例 #15
0
 void SetNextElement(IDataNode node, string name, string ns, string prefix)
 {
     this.internalNodeType = ExtensionDataNodeType.Element;
     nextElement = GetNextElement();
     nextElement.localName = name;
     nextElement.ns = ns;
     nextElement.prefix = prefix;
     if (node == null)
     {
         nextElement.attributeCount = 0;
         nextElement.AddAttribute(Globals.XsiPrefix, Globals.SchemaInstanceNamespace, Globals.XsiNilLocalName, Globals.True);
         this.internalNodeType = ExtensionDataNodeType.NullElement;
     }
     else if (!CheckIfNodeHandled(node))
     {
         AddDeserializedDataNode(node);
         node.GetData(nextElement);
         if (node is XmlDataNode)
             MoveNextInXml((XmlDataNode)node);
     }
 }
コード例 #16
0
        public override void GetData(ElementData element)
        {
            base.GetData(element);

            element.AddAttribute(Globals.SerPrefix, Globals.SerializationNamespace, Globals.ArraySizeLocalName, Size.ToString(NumberFormatInfo.InvariantInfo));
        }
コード例 #17
0
 bool CheckIfNodeHandled(IDataNode node)
 {
     bool handled = false;
     if (node.Id != Globals.NewObjectId)
     {
         handled = (cache[node] != null);
         if (handled)
         {
             if (nextElement == null)
                 nextElement = GetNextElement();
             nextElement.attributeCount = 0;
             nextElement.AddAttribute(Globals.SerPrefix, Globals.SerializationNamespace, Globals.RefLocalName, node.Id.ToString(NumberFormatInfo.InvariantInfo));
             nextElement.AddAttribute(Globals.XsiPrefix, Globals.SchemaInstanceNamespace, Globals.XsiNilLocalName, Globals.True);
             this.internalNodeType = ExtensionDataNodeType.ReferencedElement;
         }
         else
         {
             cache.Add(node, node);
         }
     }
     return handled;
 }
コード例 #18
0
ファイル: ExtensionDataReader.cs プロジェクト: dotnet/corefx
 private void PushElement()
 {
     GrowElementsIfNeeded();
     _elements[_depth++] = _element;
     if (_nextElement == null)
         _element = GetNextElement();
     else
     {
         _element = _nextElement;
         _nextElement = null;
     }
 }
コード例 #19
0
 void PushElement()
 {
     GrowElementsIfNeeded();
     elements[depth++] = this.element;
     if (nextElement == null)
         element = GetNextElement();
     else
     {
         element = nextElement;
         nextElement = null;
     }
 }
コード例 #20
0
ファイル: ExtensionDataReader.cs プロジェクト: dotnet/corefx
        private void PopElement()
        {
            _prefix = _element.prefix;
            _localName = _element.localName;
            _ns = _element.ns;

            if (_depth == 0)
                return;

            _depth--;

            if (_elements != null)
            {
                _element = _elements[_depth];
            }
        }
コード例 #21
0
 void GrowElementsIfNeeded()
 {
     if (elements == null)
         elements = new ElementData[8];
     else if (elements.Length == depth)
     {
         ElementData[] newElements = new ElementData[elements.Length * 2];
         Array.Copy(elements, 0, newElements, 0, elements.Length);
         elements = newElements;
     }
 }
コード例 #22
0
ファイル: ExtensionDataReader.cs プロジェクト: johnhhm/corefx
 private bool CheckIfNodeHandled(IDataNode node)
 {
     bool handled = false;
     if (node.Id != Globals.NewObjectId)
     {
         handled = (_cache[node] != null);
         if (handled)
         {
             if (_nextElement == null)
                 _nextElement = GetNextElement();
             _nextElement.attributeCount = 0;
             _nextElement.AddAttribute(Globals.SerPrefix, Globals.SerializationNamespace, Globals.RefLocalName, node.Id);
             _nextElement.AddAttribute(Globals.XsiPrefix, Globals.SchemaInstanceNamespace, Globals.XsiNilLocalName, Globals.True);
             _internalNodeType = ExtensionDataNodeType.ReferencedElement;
         }
         else
         {
             _cache.Add(node, node);
         }
     }
     return handled;
 }