internal static byte[] FromBinHexString(string s, bool allowOddCount) { if (s == null) { throw new ArgumentNullException("s"); } return(BinHexDecoder.Decode(s.ToCharArray(), allowOddCount)); }
private void InitBinHexDecoder() { if (binHexDecoder == null) { binHexDecoder = new BinHexDecoder(); } else { binHexDecoder.Reset(); } decoder = binHexDecoder; }
private void InitBinHexDecoder() { if (this.binHexDecoder == null) { this.binHexDecoder = new BinHexDecoder(); } else { this.binHexDecoder.Reset(); } this.decoder = this.binHexDecoder; }
private void InitBinHexDecoder() { if (_binHexDecoder == null) { _binHexDecoder = new BinHexDecoder(); } else { _binHexDecoder.Reset(); } _decoder = _binHexDecoder; }
public override async Task <int> ReadContentAsBinHexAsync(byte[] buffer, int index, int count) { switch (_state) { case State.Initial: case State.EndOfFile: case State.Closed: case State.Error: return(0); case State.ClearNsAttributes: case State.PopNamespaceScope: switch (NodeType) { case XmlNodeType.Element: throw CreateReadContentAsException("ReadContentAsBinHex"); case XmlNodeType.EndElement: return(0); case XmlNodeType.Attribute: if (_curNsAttr != -1 && reader.CanReadBinaryContent) { CheckBuffer(buffer, index, count); if (count == 0) { return(0); } if (_nsIncReadOffset == 0) { // called first time on this ns attribute if (_binDecoder != null && _binDecoder is BinHexDecoder) { _binDecoder.Reset(); } else { _binDecoder = new BinHexDecoder(); } } if (_nsIncReadOffset == _curNode.value.Length) { return(0); } _binDecoder.SetNextOutputBuffer(buffer, index, count); _nsIncReadOffset += _binDecoder.Decode(_curNode.value, _nsIncReadOffset, _curNode.value.Length - _nsIncReadOffset); return(_binDecoder.DecodedCount); } goto case XmlNodeType.Text; case XmlNodeType.Text: Debug.Assert(AttributeCount > 0); return(await reader.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false)); default: Debug.Assert(false); return(0); } case State.Interactive: _state = State.ReadContentAsBinHex; goto case State.ReadContentAsBinHex; case State.ReadContentAsBinHex: int read = await reader.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); if (read == 0) { _state = State.Interactive; ProcessNamespaces(); } return(read); case State.ReadContentAsBase64: case State.ReadElementContentAsBase64: case State.ReadElementContentAsBinHex: throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods); default: Debug.Assert(false); return(0); } }
private int IncrementalReadHelper(object destBuffer, int destIndex, IncrementalReadType readType, int srcIndex, int count) { switch (readType) { case IncrementalReadType.Chars: char[] charBuffer = destBuffer as char[]; Array.Copy(_achText, srcIndex, charBuffer, destIndex, _nPos - srcIndex); return destIndex + (_nPos - srcIndex); case IncrementalReadType.Base64: byte[] base64ByteBuffer = destBuffer as byte[]; if (null == _Base64Decoder) { _Base64Decoder = new Base64Decoder(); } return destIndex + _Base64Decoder.DecodeBase64(_achText, srcIndex, _nPos, base64ByteBuffer, destIndex, count, false); case IncrementalReadType.BinHex: byte[] binhexByteBuffer = destBuffer as byte[]; if (null == _BinHexDecoder) { _BinHexDecoder = new BinHexDecoder(); } return destIndex + _BinHexDecoder.DecodeBinHex(_achText, srcIndex, _nPos, binhexByteBuffer, destIndex, count, false); default: throw new XmlException(Res.Xml_InternalError); } // switch }
private void InitBinHexDecoder() { if (_binHexDecoder == null) { _binHexDecoder = new BinHexDecoder(); } else { _binHexDecoder.Reset(); } _incReadDecoder = _binHexDecoder; }
// Reads the contents of an element including markup and binhex-decodes it into a byte buffer. Wellformedness checks are limited. // This method is designed to read binhex-encoded large streams of bytes by calling it successively. internal int ReadBinHex(byte[] array, int offset, int len) { Debug.Assert(_v1Compat, "XmlTextReaderImpl.ReadBinHex cannot be called on reader created via XmlReader.Create."); Debug.Assert(_outerReader is XmlTextReader); if (_parsingFunction == ParsingFunction.InIncrementalRead) { if (_incReadDecoder != _binHexDecoder) { // mixing ReadBinHex with ReadChars or ReadBase64 InitBinHexDecoder(); } return IncrementalRead(array, offset, len); } else { if (_curNode.type != XmlNodeType.Element) { return 0; } if (_curNode.IsEmptyElement) { _outerReader.Read(); return 0; } if (_binHexDecoder == null) { _binHexDecoder = new BinHexDecoder(); } InitIncrementalRead(_binHexDecoder); return IncrementalRead(array, offset, len); } }
void InitBinHexDecoder() { if ( binHexDecoder == null ) { binHexDecoder = new BinHexDecoder(); } else { binHexDecoder.Reset(); } incReadDecoder = binHexDecoder; }
public override async Task<int> ReadContentAsBinHexAsync(byte[] buffer, int index, int count) { switch (_state) { case State.Initial: case State.EndOfFile: case State.Closed: case State.Error: return 0; case State.ClearNsAttributes: case State.PopNamespaceScope: switch (NodeType) { case XmlNodeType.Element: throw CreateReadContentAsException("ReadContentAsBinHex"); case XmlNodeType.EndElement: return 0; case XmlNodeType.Attribute: if (_curNsAttr != -1 && reader.CanReadBinaryContent) { CheckBuffer(buffer, index, count); if (count == 0) { return 0; } if (_nsIncReadOffset == 0) { // called first time on this ns attribute if (_binDecoder != null && _binDecoder is BinHexDecoder) { _binDecoder.Reset(); } else { _binDecoder = new BinHexDecoder(); } } if (_nsIncReadOffset == _curNode.value.Length) { return 0; } _binDecoder.SetNextOutputBuffer(buffer, index, count); _nsIncReadOffset += _binDecoder.Decode(_curNode.value, _nsIncReadOffset, _curNode.value.Length - _nsIncReadOffset); return _binDecoder.DecodedCount; } goto case XmlNodeType.Text; case XmlNodeType.Text: Debug.Assert(AttributeCount > 0); return await reader.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); default: Debug.Assert(false); return 0; } case State.Interactive: _state = State.ReadContentAsBinHex; goto case State.ReadContentAsBinHex; case State.ReadContentAsBinHex: int read = await reader.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); if (read == 0) { _state = State.Interactive; ProcessNamespaces(); } return read; case State.ReadContentAsBase64: case State.ReadElementContentAsBase64: case State.ReadElementContentAsBinHex: throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods); default: Debug.Assert(false); return 0; } }
internal static byte[] FromBinHexString(string s) { BinHexDecoder binHexDecoder = new BinHexDecoder(); return binHexDecoder.DecodeBinHex(s.ToCharArray(), 0, true); }
internal static byte[] FromBinHexString(string s) { BinHexDecoder binHexDecoder = new BinHexDecoder(); return(binHexDecoder.DecodeBinHex(s.ToCharArray(), 0, true)); }