示例#1
0
 public async static Task <T[]> ReadArrayAsync <T>(
     Serializer2 serializer,
     Dictionary <int, Object> cache,
     CancellationToken cancellation)
 {
     return(await serializer.ReadArrayAsync <T>(cache, cancellation));
 }
示例#2
0
 public static void WriteDict <K, V>(
     Dictionary <K, V> value,
     Serializer2 serializer,
     Dictionary <Object, int> cache)
 {
     serializer.WriteDict(value, cache);
 }
示例#3
0
 public static Task WriteListAsync <T>(
     List <T> list, Serializer2 serializer,
     Dictionary <Object, int> cache,
     CancellationToken cancellation)
 {
     return(serializer.WriteEnumerableAsync(list, cache, cancellation));
 }
示例#4
0
        public static T ReadEnum <T>(Serializer2 serializer) where T : struct
        {
            var str = serializer.Packer.ReadString();

            Enum.TryParse(str, out T value);
            return(value);
        }
示例#5
0
 public static Task <string> ReadStringAsync(
     Serializer2 serializer,
     Dictionary <int, Object> cache,
     CancellationToken cancellation)
 {
     return(serializer.ReadStringAsync(cache, cancellation));
 }
示例#6
0
 public static Task <List <T> > ReadListAsync <T>(
     Serializer2 serializer,
     Dictionary <int, Object> cache,
     CancellationToken cancellation)
 {
     return(serializer.ReadListAsync <T>(cache, cancellation));
 }
示例#7
0
 public static void WriteArray <T>(
     T[] array,
     Serializer2 serializer,
     Dictionary <Object, int> cache)
 {
     serializer.WriteEnumerable(array, cache);
 }
示例#8
0
 public static Task WriteArrayAsync <T>(
     T[] array, Serializer2 serializer,
     Dictionary <Object, int> cache,
     CancellationToken cancellation)
 {
     return(serializer.WriteEnumerableAsync(array, cache, cancellation));
 }
示例#9
0
 public static Task WriteStringAsync(
     string value, Serializer2 serializer,
     Dictionary <Object, int> cache,
     CancellationToken cancellation)
 {
     return(serializer.WriteStringAsync(value, cache, cancellation));
 }
示例#10
0
 public static void WriteNullable <T>(T?value, Serializer2 serializer) where T : struct
 {
     serializer.Packer.WriteBool(value.HasValue);
     if (value.HasValue)
     {
         serializer.Serialize <T>(value.Value);
     }
 }
示例#11
0
 public static Task WriteDictAsync <K, V>(
     Dictionary <K, V> value,
     Serializer2 serializer,
     Dictionary <Object, int> cache,
     CancellationToken cancellation)
 {
     return(serializer.WriteDictAsync(value, cache, cancellation));
 }
示例#12
0
        public static async Task <T> ReadEnumAsync <T>(
            Serializer2 serializer,
            CancellationToken cancellation) where T : struct
        {
            var str = await serializer.Packer.ReadStringAsync(cancellation);

            Enum.TryParse(str, out T value);
            return(value);
        }
示例#13
0
        public static async Task WriteNullableAsync <T>(
            T?value, Serializer2 serializer,
            CancellationToken cancellation) where T : struct
        {
            await serializer.Packer.WriteBoolAsync(value.HasValue, cancellation);

            if (value.HasValue)
            {
                await serializer.SerializeAsync <T>(value.Value, cancellation);
            }
        }
示例#14
0
        public static T?ReadNullable <T>(Serializer2 serializer) where T : struct
        {
            var hasValue = serializer.Packer.ReadBool();

            if (hasValue)
            {
                return(serializer.Deserialize <T>());
            }
            else
            {
                return(null);
            }
        }
示例#15
0
        public static async Task <T?> ReadNullableAsync <T>(
            Serializer2 serializer,
            CancellationToken cancellation) where T : struct
        {
            var hasValue = await serializer.Packer.ReadBoolAsync(cancellation);

            if (hasValue)
            {
                return(await serializer.DeserializeAsync <T>(cancellation));
            }
            else
            {
                return(null);
            }
        }
示例#16
0
 public static Dictionary <K, V> ReadDict <K, V>(
     Serializer2 serializer,
     Dictionary <int, Object> cache)
 {
     return(serializer.ReadDict <K, V>(cache));
 }
示例#17
0
 public static T[] ReadArray <T>(Serializer2 serializer, Dictionary <int, Object> cache)
 {
     return(serializer.ReadArray <T>(cache));
 }
示例#18
0
 public static List <T> ReadList <T>(Serializer2 serializer, Dictionary <int, Object> cache)
 {
     return(serializer.ReadList <T>(cache));
 }
示例#19
0
 public static void WriteString(
     string value, Serializer2 serializer,
     Dictionary <Object, int> cache)
 {
     serializer.WriteString(value, cache);
 }
示例#20
0
 public static void WriteList <T>(
     List <T> list, Serializer2 serializer,
     Dictionary <Object, int> cache)
 {
     serializer.WriteEnumerable(list, cache);
 }
示例#21
0
 public static void WriteEnum <T>(T value, Serializer2 serializer) where T : Enum
 {
     serializer.Packer.WriteString(value.ToString());
 }
示例#22
0
 public static string ReadString(Serializer2 serializer, Dictionary <int, Object> cache)
 {
     return(serializer.ReadString(cache));
 }
示例#23
0
 public static Task WriteEnumAsync <T>(
     T value, Serializer2 serializer,
     CancellationToken cancellation) where T : Enum
 {
     return(serializer.Packer.WriteStringAsync(value.ToString(), cancellation));
 }