コード例 #1
0
ファイル: BinaryDataWriter.cs プロジェクト: S031/MetaStack
 public unsafe BinaryDataWriter Write(ExportedDataTypes type)
 {
     CheckAndResizeBuffer(sizeof(byte));
     *(byte *)_buffer.Ref = (byte)type;
     _buffer.Skip();
     return(this);
 }
コード例 #2
0
ファイル: Json.Binary.cs プロジェクト: S031/MetaStack
        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);
        }
コード例 #3
0
ファイル: SimpleValue.cs プロジェクト: S031/MetaStack
 public SimpleValue2(string value)
 {
     _value  = false;
     _buffer = new BinaryDataWriter(value.Length * sizeof(char) + sizeof(int) + 1)
               .Write(value)
               .GetBytes();
     _type = ExportedDataTypes.@string;
 }
コード例 #4
0
ファイル: BinaryDataWriter.cs プロジェクト: S031/MetaStack
        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);
        }
コード例 #5
0
ファイル: SimpleValue.cs プロジェクト: S031/MetaStack
 public SimpleValue2(int value)
 {
     _value  = value;
     _buffer = null;
     _type   = ExportedDataTypes.@int;
 }