private void WriteTextNodeWithLength(XmlBinaryNodeType nodeType, int length) { DiagnosticUtility.DebugAssert(nodeType == XmlBinaryNodeType.Chars8Text || nodeType == XmlBinaryNodeType.Bytes8Text || nodeType == XmlBinaryNodeType.UnicodeChars8Text, ""); int offset; byte[] buffer = GetTextNodeBuffer(5, out offset); if (length < 256) { buffer[offset + 0] = (byte)nodeType; buffer[offset + 1] = (byte)length; Advance(2); } else if (length < 65536) { buffer[offset + 0] = (byte)(nodeType + 1 * 2); // WithEndElements interleave buffer[offset + 1] = (byte)length; length >>= 8; buffer[offset + 2] = (byte)length; Advance(3); } else { buffer[offset + 0] = (byte)(nodeType + 2 * 2); // WithEndElements interleave buffer[offset + 1] = (byte)length; length >>= 8; buffer[offset + 2] = (byte)length; length >>= 8; buffer[offset + 3] = (byte)length; length >>= 8; buffer[offset + 4] = (byte)length; Advance(5); } }
private void WriteTextNode(XmlBinaryNodeType nodeType) { if (_inAttribute) WroteAttributeValue(); DiagnosticUtility.DebugAssert(nodeType >= XmlBinaryNodeType.MinText && nodeType <= XmlBinaryNodeType.MaxText && ((byte)nodeType & 1) == 0, "Invalid nodeType"); WriteByte((byte)nodeType); _textNodeOffset = this.BufferOffset - 1; }
void WriteTextNode(XmlBinaryNodeType nodeType) { if (inAttribute) WroteAttributeValue(); Fx.Assert(nodeType >= XmlBinaryNodeType.MinText && nodeType <= XmlBinaryNodeType.MaxText && ((byte)nodeType & 1) == 0, "Invalid nodeType"); WriteByte((byte)nodeType); textNodeOffset = this.BufferOffset - 1; }
private void InsertNode(XmlBinaryNodeType nodeType, int length) { byte[] buffer = new byte[5]; buffer[0] = (byte) nodeType; buffer[1] = (byte) length; length = length >> 8; buffer[2] = (byte) length; length = length >> 8; buffer[3] = (byte) length; length = length >> 8; buffer[4] = (byte) length; base.BufferReader.InsertBytes(buffer, 0, buffer.Length); }
private void ReadList(ValueHandle value) { _listValue ??= new ValueHandle(this); int count = 0; int offset = this.Offset; while (true) { XmlBinaryNodeType nodeType = GetNodeType(); SkipNodeType(); if (nodeType == XmlBinaryNodeType.StartListText) { XmlExceptionHelper.ThrowInvalidBinaryFormat(_reader); } if (nodeType == XmlBinaryNodeType.EndListText) { break; } ReadValue(nodeType, _listValue); count++; } value.SetValue(ValueHandleType.List, offset, count); }
private void WriteTextNodeWithInt64(XmlBinaryNodeType nodeType, long value) { int num; byte[] textNodeBuffer = this.GetTextNodeBuffer(9, out num); textNodeBuffer[num] = (byte)nodeType; textNodeBuffer[num + 1] = (byte)value; value = value >> 8; textNodeBuffer[num + 2] = (byte)value; value = value >> 8; textNodeBuffer[num + 3] = (byte)value; value = value >> 8; textNodeBuffer[num + 4] = (byte)value; value = value >> 8; textNodeBuffer[num + 5] = (byte)value; value = value >> 8; textNodeBuffer[num + 6] = (byte)value; value = value >> 8; textNodeBuffer[num + 7] = (byte)value; value = value >> 8; textNodeBuffer[num + 8] = (byte)value; base.Advance(9); }
public object[] GetList(int offset, int count) { int bufferOffset = this.Offset; this.Offset = offset; try { object[] objects = new object[count]; for (int i = 0; i < count; i++) { XmlBinaryNodeType nodeType = GetNodeType(); SkipNodeType(); DiagnosticUtility.DebugAssert(nodeType != XmlBinaryNodeType.StartListText, ""); ReadValue(nodeType, _listValue); objects[i] = _listValue.ToObject(); } return(objects); } finally { this.Offset = bufferOffset; } }
public object[] GetList(int offset, int count) { object[] objArray2; int num = this.Offset; this.Offset = offset; try { object[] objArray = new object[count]; for (int i = 0; i < count; i++) { XmlBinaryNodeType nodeType = this.GetNodeType(); this.SkipNodeType(); this.ReadValue(nodeType, this.listValue); objArray[i] = this.listValue.ToObject(); } objArray2 = objArray; } finally { this.Offset = num; } return(objArray2); }
private void WriteNode(XmlBinaryNodeType nodeType) { WriteByte((byte)nodeType); _textNodeOffset = -1; }
private void WriteTextNode(XmlBinaryNodeType nodeType) { if (this.inAttribute) { this.WroteAttributeValue(); } base.WriteByte((byte) nodeType); this.textNodeOffset = base.BufferOffset - 1; }
public void ReadValue(XmlBinaryNodeType nodeType, ValueHandle value) { switch (nodeType) { case XmlBinaryNodeType.EmptyText: value.SetValue(ValueHandleType.Empty); break; case XmlBinaryNodeType.ZeroText: value.SetValue(ValueHandleType.Zero); break; case XmlBinaryNodeType.OneText: value.SetValue(ValueHandleType.One); break; case XmlBinaryNodeType.TrueText: value.SetValue(ValueHandleType.True); break; case XmlBinaryNodeType.FalseText: value.SetValue(ValueHandleType.False); break; case XmlBinaryNodeType.BoolText: value.SetValue(ReadUInt8() != 0 ? ValueHandleType.True : ValueHandleType.False); break; case XmlBinaryNodeType.Chars8Text: ReadValue(value, ValueHandleType.UTF8, ReadUInt8()); break; case XmlBinaryNodeType.Chars16Text: ReadValue(value, ValueHandleType.UTF8, ReadUInt16()); break; case XmlBinaryNodeType.Chars32Text: ReadValue(value, ValueHandleType.UTF8, ReadUInt31()); break; case XmlBinaryNodeType.UnicodeChars8Text: ReadUnicodeValue(value, ReadUInt8()); break; case XmlBinaryNodeType.UnicodeChars16Text: ReadUnicodeValue(value, ReadUInt16()); break; case XmlBinaryNodeType.UnicodeChars32Text: ReadUnicodeValue(value, ReadUInt31()); break; case XmlBinaryNodeType.Bytes8Text: ReadValue(value, ValueHandleType.Base64, ReadUInt8()); break; case XmlBinaryNodeType.Bytes16Text: ReadValue(value, ValueHandleType.Base64, ReadUInt16()); break; case XmlBinaryNodeType.Bytes32Text: ReadValue(value, ValueHandleType.Base64, ReadUInt31()); break; case XmlBinaryNodeType.DictionaryText: value.SetDictionaryValue(ReadDictionaryKey()); break; case XmlBinaryNodeType.UniqueIdText: ReadValue(value, ValueHandleType.UniqueId, ValueHandleLength.UniqueId); break; case XmlBinaryNodeType.GuidText: ReadValue(value, ValueHandleType.Guid, ValueHandleLength.Guid); break; case XmlBinaryNodeType.DecimalText: ReadValue(value, ValueHandleType.Decimal, ValueHandleLength.Decimal); break; case XmlBinaryNodeType.Int8Text: ReadValue(value, ValueHandleType.Int8, ValueHandleLength.Int8); break; case XmlBinaryNodeType.Int16Text: ReadValue(value, ValueHandleType.Int16, ValueHandleLength.Int16); break; case XmlBinaryNodeType.Int32Text: ReadValue(value, ValueHandleType.Int32, ValueHandleLength.Int32); break; case XmlBinaryNodeType.Int64Text: ReadValue(value, ValueHandleType.Int64, ValueHandleLength.Int64); break; case XmlBinaryNodeType.UInt64Text: ReadValue(value, ValueHandleType.UInt64, ValueHandleLength.UInt64); break; case XmlBinaryNodeType.FloatText: ReadValue(value, ValueHandleType.Single, ValueHandleLength.Single); break; case XmlBinaryNodeType.DoubleText: ReadValue(value, ValueHandleType.Double, ValueHandleLength.Double); break; case XmlBinaryNodeType.TimeSpanText: ReadValue(value, ValueHandleType.TimeSpan, ValueHandleLength.TimeSpan); break; case XmlBinaryNodeType.DateTimeText: ReadValue(value, ValueHandleType.DateTime, ValueHandleLength.DateTime); break; case XmlBinaryNodeType.StartListText: ReadList(value); break; case XmlBinaryNodeType.QNameDictionaryText: ReadQName(value); break; default: XmlExceptionHelper.ThrowInvalidBinaryFormat(_reader); break; } }
private void WriteTextNodeWithLength(XmlBinaryNodeType nodeType, int length) { int num; byte[] textNodeBuffer = this.GetTextNodeBuffer(5, out num); if (length < 0x100) { textNodeBuffer[num] = (byte) nodeType; textNodeBuffer[num + 1] = (byte) length; base.Advance(2); } else if (length < 0x10000) { textNodeBuffer[num] = (byte) (nodeType + 2); textNodeBuffer[num + 1] = (byte) length; length = length >> 8; textNodeBuffer[num + 2] = (byte) length; base.Advance(3); } else { textNodeBuffer[num] = (byte) (nodeType + 4); textNodeBuffer[num + 1] = (byte) length; length = length >> 8; textNodeBuffer[num + 2] = (byte) length; length = length >> 8; textNodeBuffer[num + 3] = (byte) length; length = length >> 8; textNodeBuffer[num + 4] = (byte) length; base.Advance(5); } }
private bool IsStartArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, XmlBinaryNodeType nodeType) { return (((this.IsStartElement(localName, namespaceUri) && (this.arrayState == ArrayState.Element)) && (this.arrayNodeType == nodeType)) && !base.Signing); }
private void WriteNode(XmlBinaryNodeType nodeType) { base.WriteByte((byte) nodeType); this.textNodeOffset = -1; }
public unsafe void UnsafeWriteArray(XmlBinaryNodeType nodeType, int count, byte* array, byte* arrayMax) { WriteArrayInfo(nodeType, count); UnsafeWriteArray(array, (int)(arrayMax - array)); }
private void WriteNode(XmlBinaryNodeType nodeType) { base.WriteByte((byte)nodeType); this.textNodeOffset = -1; }
bool IsStartArray(string localName, string namespaceUri, XmlBinaryNodeType nodeType) { return IsStartElement(localName, namespaceUri) && arrayState == ArrayState.Element && arrayNodeType == nodeType && !Signing; }
public void ReadValue(XmlBinaryNodeType nodeType, ValueHandle value) { switch (nodeType) { case XmlBinaryNodeType.MinText: value.SetValue(ValueHandleType.Zero); return; case XmlBinaryNodeType.OneText: value.SetValue(ValueHandleType.One); return; case XmlBinaryNodeType.FalseText: value.SetValue(ValueHandleType.False); return; case XmlBinaryNodeType.TrueText: value.SetValue(ValueHandleType.True); return; case XmlBinaryNodeType.Int8Text: this.ReadValue(value, ValueHandleType.Int8, 1); return; case XmlBinaryNodeType.Int16Text: this.ReadValue(value, ValueHandleType.Int16, 2); return; case XmlBinaryNodeType.Int32Text: this.ReadValue(value, ValueHandleType.Int32, 4); return; case XmlBinaryNodeType.Int64Text: this.ReadValue(value, ValueHandleType.Int64, 8); return; case XmlBinaryNodeType.FloatText: this.ReadValue(value, ValueHandleType.Single, 4); return; case XmlBinaryNodeType.DoubleText: this.ReadValue(value, ValueHandleType.Double, 8); return; case XmlBinaryNodeType.DecimalText: this.ReadValue(value, ValueHandleType.Decimal, 0x10); return; case XmlBinaryNodeType.DateTimeText: this.ReadValue(value, ValueHandleType.DateTime, 8); return; case XmlBinaryNodeType.Chars8Text: this.ReadValue(value, ValueHandleType.UTF8, this.ReadUInt8()); return; case XmlBinaryNodeType.Chars16Text: this.ReadValue(value, ValueHandleType.UTF8, this.ReadUInt16()); return; case XmlBinaryNodeType.Chars32Text: this.ReadValue(value, ValueHandleType.UTF8, this.ReadUInt31()); return; case XmlBinaryNodeType.Bytes8Text: this.ReadValue(value, ValueHandleType.Base64, this.ReadUInt8()); return; case XmlBinaryNodeType.Bytes16Text: this.ReadValue(value, ValueHandleType.Base64, this.ReadUInt16()); return; case XmlBinaryNodeType.Bytes32Text: this.ReadValue(value, ValueHandleType.Base64, this.ReadUInt31()); return; case XmlBinaryNodeType.StartListText: this.ReadList(value); return; case XmlBinaryNodeType.EmptyText: value.SetValue(ValueHandleType.Empty); return; case XmlBinaryNodeType.DictionaryText: value.SetDictionaryValue(this.ReadDictionaryKey()); return; case XmlBinaryNodeType.UniqueIdText: this.ReadValue(value, ValueHandleType.UniqueId, 0x10); return; case XmlBinaryNodeType.TimeSpanText: this.ReadValue(value, ValueHandleType.TimeSpan, 8); return; case XmlBinaryNodeType.GuidText: this.ReadValue(value, ValueHandleType.Guid, 0x10); return; case XmlBinaryNodeType.UInt64Text: this.ReadValue(value, ValueHandleType.UInt64, 8); return; case XmlBinaryNodeType.BoolText: value.SetValue((this.ReadUInt8() != 0) ? ValueHandleType.True : ValueHandleType.False); return; case XmlBinaryNodeType.UnicodeChars8Text: this.ReadUnicodeValue(value, this.ReadUInt8()); return; case XmlBinaryNodeType.UnicodeChars16Text: this.ReadUnicodeValue(value, this.ReadUInt16()); return; case XmlBinaryNodeType.UnicodeChars32Text: this.ReadUnicodeValue(value, this.ReadUInt31()); return; case XmlBinaryNodeType.QNameDictionaryText: this.ReadQName(value); return; } XmlExceptionHelper.ThrowInvalidBinaryFormat(this.reader); }
public unsafe void UnsafeWriteArray(XmlBinaryNodeType nodeType, int count, byte *array, byte *arrayMax) { this.WriteArrayInfo(nodeType, count); this.UnsafeWriteArray(array, (int)((long)((arrayMax - array) / 1))); }
public unsafe void UnsafeWriteArray(XmlBinaryNodeType nodeType, int count, byte* array, byte* arrayMax) { this.WriteArrayInfo(nodeType, count); this.UnsafeWriteArray(array, (int) ((long) ((arrayMax - array) / 1))); }
private void WritePrefixNode(XmlBinaryNodeType nodeType, int ch) { this.WriteNode(nodeType + ch); }
private void WritePrefixNode(XmlBinaryNodeType nodeType, int ch) { this.WriteNode(nodeType + ch); }
public void ReadValue(XmlBinaryNodeType nodeType, ValueHandle value) { switch (nodeType) { case XmlBinaryNodeType.EmptyText: value.SetValue(ValueHandleType.Empty); break; case XmlBinaryNodeType.ZeroText: value.SetValue(ValueHandleType.Zero); break; case XmlBinaryNodeType.OneText: value.SetValue(ValueHandleType.One); break; case XmlBinaryNodeType.TrueText: value.SetValue(ValueHandleType.True); break; case XmlBinaryNodeType.FalseText: value.SetValue(ValueHandleType.False); break; case XmlBinaryNodeType.BoolText: value.SetValue(ReadUInt8() != 0 ? ValueHandleType.True : ValueHandleType.False); break; case XmlBinaryNodeType.Chars8Text: ReadValue(value, ValueHandleType.UTF8, ReadUInt8()); break; case XmlBinaryNodeType.Chars16Text: ReadValue(value, ValueHandleType.UTF8, ReadUInt16()); break; case XmlBinaryNodeType.Chars32Text: ReadValue(value, ValueHandleType.UTF8, ReadUInt31()); break; case XmlBinaryNodeType.UnicodeChars8Text: ReadUnicodeValue(value, ReadUInt8()); break; case XmlBinaryNodeType.UnicodeChars16Text: ReadUnicodeValue(value, ReadUInt16()); break; case XmlBinaryNodeType.UnicodeChars32Text: ReadUnicodeValue(value, ReadUInt31()); break; case XmlBinaryNodeType.Bytes8Text: ReadValue(value, ValueHandleType.Base64, ReadUInt8()); break; case XmlBinaryNodeType.Bytes16Text: ReadValue(value, ValueHandleType.Base64, ReadUInt16()); break; case XmlBinaryNodeType.Bytes32Text: ReadValue(value, ValueHandleType.Base64, ReadUInt31()); break; case XmlBinaryNodeType.DictionaryText: value.SetDictionaryValue(ReadDictionaryKey()); break; case XmlBinaryNodeType.UniqueIdText: ReadValue(value, ValueHandleType.UniqueId, ValueHandleLength.UniqueId); break; case XmlBinaryNodeType.GuidText: ReadValue(value, ValueHandleType.Guid, ValueHandleLength.Guid); break; case XmlBinaryNodeType.DecimalText: ReadValue(value, ValueHandleType.Decimal, ValueHandleLength.Decimal); break; case XmlBinaryNodeType.Int8Text: ReadValue(value, ValueHandleType.Int8, ValueHandleLength.Int8); break; case XmlBinaryNodeType.Int16Text: ReadValue(value, ValueHandleType.Int16, ValueHandleLength.Int16); break; case XmlBinaryNodeType.Int32Text: ReadValue(value, ValueHandleType.Int32, ValueHandleLength.Int32); break; case XmlBinaryNodeType.Int64Text: ReadValue(value, ValueHandleType.Int64, ValueHandleLength.Int64); break; case XmlBinaryNodeType.UInt64Text: ReadValue(value, ValueHandleType.UInt64, ValueHandleLength.UInt64); break; case XmlBinaryNodeType.FloatText: ReadValue(value, ValueHandleType.Single, ValueHandleLength.Single); break; case XmlBinaryNodeType.DoubleText: ReadValue(value, ValueHandleType.Double, ValueHandleLength.Double); break; case XmlBinaryNodeType.TimeSpanText: ReadValue(value, ValueHandleType.TimeSpan, ValueHandleLength.TimeSpan); break; case XmlBinaryNodeType.DateTimeText: ReadValue(value, ValueHandleType.DateTime, ValueHandleLength.DateTime); break; case XmlBinaryNodeType.StartListText: ReadList(value); break; case XmlBinaryNodeType.QNameDictionaryText: ReadQName(value); break; default: XmlExceptionHelper.ThrowInvalidBinaryFormat(reader); break; } }
private void WriteArrayInfo(XmlBinaryNodeType nodeType, int count) { WriteNode(nodeType); WriteMultiByteInt32(count); }
private void WriteArrayInfo(XmlBinaryNodeType nodeType, int count) { this.WriteNode(nodeType); this.WriteMultiByteInt32(count); }
private unsafe void UnsafeWriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, XmlBinaryNodeType nodeType, int count, byte *array, byte *arrayMax) { this.WriteStartArray(prefix, localName, namespaceUri, count); this.writer.UnsafeWriteArray(nodeType, count, array, arrayMax); this.WriteEndArray(); }
public void ReadValue(XmlBinaryNodeType nodeType, ValueHandle value) { switch (nodeType) { case XmlBinaryNodeType.MinText: value.SetValue(ValueHandleType.Zero); return; case XmlBinaryNodeType.OneText: value.SetValue(ValueHandleType.One); return; case XmlBinaryNodeType.FalseText: value.SetValue(ValueHandleType.False); return; case XmlBinaryNodeType.TrueText: value.SetValue(ValueHandleType.True); return; case XmlBinaryNodeType.Int8Text: this.ReadValue(value, ValueHandleType.Int8, 1); return; case XmlBinaryNodeType.Int16Text: this.ReadValue(value, ValueHandleType.Int16, 2); return; case XmlBinaryNodeType.Int32Text: this.ReadValue(value, ValueHandleType.Int32, 4); return; case XmlBinaryNodeType.Int64Text: this.ReadValue(value, ValueHandleType.Int64, 8); return; case XmlBinaryNodeType.FloatText: this.ReadValue(value, ValueHandleType.Single, 4); return; case XmlBinaryNodeType.DoubleText: this.ReadValue(value, ValueHandleType.Double, 8); return; case XmlBinaryNodeType.DecimalText: this.ReadValue(value, ValueHandleType.Decimal, 0x10); return; case XmlBinaryNodeType.DateTimeText: this.ReadValue(value, ValueHandleType.DateTime, 8); return; case XmlBinaryNodeType.Chars8Text: this.ReadValue(value, ValueHandleType.UTF8, this.ReadUInt8()); return; case XmlBinaryNodeType.Chars16Text: this.ReadValue(value, ValueHandleType.UTF8, this.ReadUInt16()); return; case XmlBinaryNodeType.Chars32Text: this.ReadValue(value, ValueHandleType.UTF8, this.ReadUInt31()); return; case XmlBinaryNodeType.Bytes8Text: this.ReadValue(value, ValueHandleType.Base64, this.ReadUInt8()); return; case XmlBinaryNodeType.Bytes16Text: this.ReadValue(value, ValueHandleType.Base64, this.ReadUInt16()); return; case XmlBinaryNodeType.Bytes32Text: this.ReadValue(value, ValueHandleType.Base64, this.ReadUInt31()); return; case XmlBinaryNodeType.StartListText: this.ReadList(value); return; case XmlBinaryNodeType.EmptyText: value.SetValue(ValueHandleType.Empty); return; case XmlBinaryNodeType.DictionaryText: value.SetDictionaryValue(this.ReadDictionaryKey()); return; case XmlBinaryNodeType.UniqueIdText: this.ReadValue(value, ValueHandleType.UniqueId, 0x10); return; case XmlBinaryNodeType.TimeSpanText: this.ReadValue(value, ValueHandleType.TimeSpan, 8); return; case XmlBinaryNodeType.GuidText: this.ReadValue(value, ValueHandleType.Guid, 0x10); return; case XmlBinaryNodeType.UInt64Text: this.ReadValue(value, ValueHandleType.UInt64, 8); return; case XmlBinaryNodeType.BoolText: value.SetValue((this.ReadUInt8() != 0) ? ValueHandleType.True : ValueHandleType.False); return; case XmlBinaryNodeType.UnicodeChars8Text: this.ReadUnicodeValue(value, this.ReadUInt8()); return; case XmlBinaryNodeType.UnicodeChars16Text: this.ReadUnicodeValue(value, this.ReadUInt16()); return; case XmlBinaryNodeType.UnicodeChars32Text: this.ReadUnicodeValue(value, this.ReadUInt31()); return; case XmlBinaryNodeType.QNameDictionaryText: this.ReadQName(value); return; } XmlExceptionHelper.ThrowInvalidBinaryFormat(this.reader); }
private void AddTreeNode(TreeNode rootNode, XmlBinaryNode node) { TreeNode childNode = rootNode.Nodes.Add(node.ToString(this.staticDictionary, this.readerSession, false)); foreach (XmlBinaryNode child in node.Children) { this.AddTreeNode(childNode, child); } if (node.NodeType == XmlBinaryNodeType.Array) { Array elements = null; BinaryArrayElements arrayElements = node.ArrayElements; byte nodeType = arrayElements.NodeType; string nodeTypeName = XmlBinaryNodeType.GetNodeName((byte)(nodeType & 0xFE)); switch (arrayElements.NodeType) { case XmlBinaryNodeType.Int16Text: case XmlBinaryNodeType.Int16TextWithEndElement: elements = arrayElements.ShortArray; break; case XmlBinaryNodeType.Int32Text: case XmlBinaryNodeType.Int32TextWithEndElement: elements = arrayElements.IntArray; break; case XmlBinaryNodeType.Int64Text: case XmlBinaryNodeType.Int64TextWithEndElement: elements = arrayElements.LongArray; break; case XmlBinaryNodeType.BoolText: case XmlBinaryNodeType.BoolTextWithEndElement: elements = arrayElements.BoolArray; break; case XmlBinaryNodeType.DateTimeText: case XmlBinaryNodeType.DateTimeTextWithEndElement: elements = arrayElements.DateTimeArray; break; case XmlBinaryNodeType.DecimalText: case XmlBinaryNodeType.DecimalTextWithEndElement: elements = arrayElements.DecimalArray; break; case XmlBinaryNodeType.DoubleText: case XmlBinaryNodeType.DoubleTextWithEndElement: elements = arrayElements.DoubleArray; break; case XmlBinaryNodeType.FloatText: case XmlBinaryNodeType.FloatTextWithEndElement: elements = arrayElements.FloatArray; break; case XmlBinaryNodeType.GuidText: case XmlBinaryNodeType.GuidTextWithEndElement: elements = arrayElements.GuidArray; break; case XmlBinaryNodeType.TimeSpanText: case XmlBinaryNodeType.TimeSpanTextWithEndElement: elements = arrayElements.TimeSpanArray; break; } if (elements != null) { if (nodeTypeName.EndsWith("Text")) { nodeTypeName = nodeTypeName.Substring(0, nodeTypeName.Length - 4); } foreach (var item in elements) { rootNode.Nodes.Add(string.Format(CultureInfo.InvariantCulture, "({0}) {1}", nodeTypeName, item)); } } } }
private void ReadArray() { if (GetNodeType() == XmlBinaryNodeType.Array) // Prevent recursion XmlExceptionHelper.ThrowInvalidBinaryFormat(this); ReadNode(); // ReadStartElement if (this.Node.NodeType != XmlNodeType.Element) XmlExceptionHelper.ThrowInvalidBinaryFormat(this); if (GetNodeType() == XmlBinaryNodeType.Array) // Prevent recursion XmlExceptionHelper.ThrowInvalidBinaryFormat(this); ReadNode(); // ReadEndElement if (this.Node.NodeType != XmlNodeType.EndElement) XmlExceptionHelper.ThrowInvalidBinaryFormat(this); _arrayState = ArrayState.Element; _arrayNodeType = GetNodeType(); if (!IsValidArrayType(_arrayNodeType)) XmlExceptionHelper.ThrowInvalidBinaryFormat(this); SkipNodeType(); _arrayCount = ReadMultiByteUInt31(); if (_arrayCount == 0) XmlExceptionHelper.ThrowInvalidBinaryFormat(this); MoveToArrayElement(); }
private void ReadArray() { if (this.GetNodeType() == XmlBinaryNodeType.Array) { XmlExceptionHelper.ThrowInvalidBinaryFormat(this); } this.ReadNode(); if (base.Node.NodeType != XmlNodeType.Element) { XmlExceptionHelper.ThrowInvalidBinaryFormat(this); } if (this.GetNodeType() == XmlBinaryNodeType.Array) { XmlExceptionHelper.ThrowInvalidBinaryFormat(this); } this.ReadNode(); if (base.Node.NodeType != XmlNodeType.EndElement) { XmlExceptionHelper.ThrowInvalidBinaryFormat(this); } this.arrayState = ArrayState.Element; this.arrayNodeType = this.GetNodeType(); if (!this.IsValidArrayType(this.arrayNodeType)) { XmlExceptionHelper.ThrowInvalidBinaryFormat(this); } this.SkipNodeType(); this.arrayCount = this.ReadMultiByteUInt31(); if (this.arrayCount == 0) { XmlExceptionHelper.ThrowInvalidBinaryFormat(this); } this.MoveToArrayElement(); }
private unsafe void UnsafeWriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, XmlBinaryNodeType nodeType, int count, byte* array, byte* arrayMax) { WriteStartArray(prefix, localName, namespaceUri, count); _writer.UnsafeWriteArray(nodeType, count, array, arrayMax); WriteEndArray(); }
private void AppendNode(XmlBinaryNodeType value) { this.AppendByte((int)value); }
private void WritePrefixNode(XmlBinaryNodeType nodeType, int ch) { WriteNode((XmlBinaryNodeType)((int)nodeType + ch)); }
private bool IsValidArrayType(XmlBinaryNodeType nodeType) { switch (nodeType) { case XmlBinaryNodeType.BoolTextWithEndElement: case XmlBinaryNodeType.Int16TextWithEndElement: case XmlBinaryNodeType.Int32TextWithEndElement: case XmlBinaryNodeType.Int64TextWithEndElement: case XmlBinaryNodeType.FloatTextWithEndElement: case XmlBinaryNodeType.DoubleTextWithEndElement: case XmlBinaryNodeType.DecimalTextWithEndElement: case XmlBinaryNodeType.DateTimeTextWithEndElement: case XmlBinaryNodeType.TimeSpanTextWithEndElement: case XmlBinaryNodeType.GuidTextWithEndElement: return true; default: return false; } }
private void WriteTextNodeWithInt64(XmlBinaryNodeType nodeType, long value) { int num; byte[] textNodeBuffer = this.GetTextNodeBuffer(9, out num); textNodeBuffer[num] = (byte) nodeType; textNodeBuffer[num + 1] = (byte) value; value = value >> 8; textNodeBuffer[num + 2] = (byte) value; value = value >> 8; textNodeBuffer[num + 3] = (byte) value; value = value >> 8; textNodeBuffer[num + 4] = (byte) value; value = value >> 8; textNodeBuffer[num + 5] = (byte) value; value = value >> 8; textNodeBuffer[num + 6] = (byte) value; value = value >> 8; textNodeBuffer[num + 7] = (byte) value; value = value >> 8; textNodeBuffer[num + 8] = (byte) value; base.Advance(9); }
private bool IsStartArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, XmlBinaryNodeType nodeType) { return IsStartElement(localName, namespaceUri) && _arrayState == ArrayState.Element && _arrayNodeType == nodeType; }
private void WriteTextNodeWithInt64(XmlBinaryNodeType nodeType, Int64 value) { int offset; byte[] buffer = GetTextNodeBuffer(9, out offset); buffer[offset + 0] = (byte)nodeType; buffer[offset + 1] = (byte)value; value >>= 8; buffer[offset + 2] = (byte)value; value >>= 8; buffer[offset + 3] = (byte)value; value >>= 8; buffer[offset + 4] = (byte)value; value >>= 8; buffer[offset + 5] = (byte)value; value >>= 8; buffer[offset + 6] = (byte)value; value >>= 8; buffer[offset + 7] = (byte)value; value >>= 8; buffer[offset + 8] = (byte)value; Advance(9); }