Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ToByteArray()

byte[] System.Xml.ValueHandle.ToByteArray ( )
inline

Definition at line 398 of file ValueHandle.cs.

399 {
400 if (_type == ValueHandleType.Base64)
401 {
402 byte[] array = new byte[_length];
404 return array;
405 }
406 if (_type == ValueHandleType.UTF8 && _length % 4 == 0)
407 {
408 try
409 {
410 int num = _length / 4 * 3;
411 if (_length > 0 && _bufferReader.Buffer[_offset + _length - 1] == 61)
412 {
413 num--;
414 if (_bufferReader.Buffer[_offset + _length - 2] == 61)
415 {
416 num--;
417 }
418 }
419 byte[] array2 = new byte[num];
421 if (bytes != array2.Length)
422 {
423 byte[] array3 = new byte[bytes];
424 Buffer.BlockCopy(array2, 0, array3, 0, bytes);
425 array2 = array3;
426 }
427 return array2;
428 }
429 catch (FormatException)
430 {
431 }
432 }
433 try
434 {
435 return Base64Encoding.GetBytes(XmlConverter.StripWhitespace(GetString()));
436 }
437 catch (FormatException ex2)
438 {
439 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(ex2.Message, ex2.InnerException));
440 }
441 }
unsafe override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
ValueHandleType _type
void GetBase64(byte[] buffer, int offset, int count)
readonly XmlBufferReader _bufferReader
Definition ValueHandle.cs:9

References System.Xml.ValueHandle._bufferReader, System.Xml.ValueHandle._length, System.Xml.ValueHandle._offset, System.Xml.ValueHandle._type, System.array, System.Buffer.BlockCopy(), System.Xml.XmlBufferReader.Buffer, System.bytes, System.Xml.Dictionary, System.Xml.ValueHandle.GetBase64(), System.Text.Base64Encoding.GetBytes(), System.Xml.ValueHandle.GetString(), System.Xml.XmlConverter.StripWhitespace(), System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(), and System.Xml.XmlException.

Referenced by System.Xml.ValueHandle.GetString(), System.Xml.XmlBaseReader.ReadContentAsBase64(), and System.Xml.ValueHandle.ToObject().