public unsafe BinaryDataWriter Write(ExportedDataTypes type) { CheckAndResizeBuffer(sizeof(byte)); *(byte *)_buffer.Ref = (byte)type; _buffer.Skip(); return(this); }
public static JsonValue FromBinary(this JsonValue jsonValue, byte[] source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } var r = new BinaryDataReader((BinaryDataBuffer)source); ExportedDataTypes t = r.ReadNext(); if (t == ExportedDataTypes.@object) { ReadRaw((JsonObject)jsonValue, ref r); } else if (t == ExportedDataTypes.array) { ReadArrayRaw((JsonArray)jsonValue, ref r); } else { throw new FormatException("Invalid format for source data. Start type must be object or array."); } return(jsonValue); }
public SimpleValue2(string value) { _value = false; _buffer = new BinaryDataWriter(value.Length * sizeof(char) + sizeof(int) + 1) .Write(value) .GetBytes(); _type = ExportedDataTypes.@string; }
public unsafe BinaryDataWriter Write(long value, ExportedDataTypes type = ExportedDataTypes.@long) { CheckAndResizeBuffer(sizeof(long) + 1); *(byte *)_buffer.Ref = (byte)type; _buffer.Skip(); *(long *)_buffer.Ref = value; _buffer.Skip(sizeof(long)); return(this); }
public SimpleValue2(int value) { _value = value; _buffer = null; _type = ExportedDataTypes.@int; }