Exemple #1
0
 public static IValueDeserializerProviderBuilder <TPacketReader> Set <TPacketReader, TValue, TResult>(
     this IValueDeserializerProviderBuilder <TPacketReader> Builder,
     Func <TResult, IFieldOption, TValue> Deserialize,
     string Channel = null,
     string Field   = null
     ) where TPacketReader : DictPacketReader <TResult>
 {
     Builder.Set(
         (r, f) => Deserialize(r.Read(f), f),
         Channel,
         Field
         );
     return(Builder);
 }
Exemple #2
0
 public static IValueDeserializerProviderBuilder <TPacketReader> Set <TPacketReader, TValue>(
     this IValueDeserializerProviderBuilder <TPacketReader> Builder,
     Func <TPacketReader, IFieldOption, TValue> Deserialize,
     string Channel = null,
     string Field   = null
     )
 {
     Builder.Set(
         new FuncValueDeserializer <TPacketReader, TValue> {
         FuncDeserialize = Deserialize
     },
         Channel,
         Field
         );
     return(Builder);
 }
Exemple #3
0
 public static IValueDeserializerProviderBuilder <TPacketReader> SetToString <TPacketReader, TValue>(
     this IValueDeserializerProviderBuilder <TPacketReader> Builder,
     Func <string, TValue> Convert,
     string Format  = null,
     string Channel = null,
     string Field   = null
     ) where TPacketReader : DictPacketReader <string>
 {
     if (Format == null)
     {
         Builder.Set <TPacketReader, TValue, string>((r, f) => r.Read <TValue> r.re.ToString(), Channel, Field);
     }
     else
     {
         Builder.Set <TPacketReader, TValue, string>((r, f) => string.Format(Format, v), Channel, Field);
     }
     return(Builder);
 }
Exemple #4
0
        public static IValueDeserializerProviderBuilder <TPacketReader> SetStringValueDeserializers <TPacketReader>(
            this IValueDeserializerProviderBuilder <TPacketReader> Builder
            ) where TPacketReader : DictPacketReader <string>
        {
            Builder.Set((r, f) => sbyte.Parse(r.Read(f)));
            Builder.SetToString <TPacketWriter, byte>();
            Builder.SetToString <TPacketWriter, short>();
            Builder.SetToString <TPacketWriter, ushort>();
            Builder.SetToString <TPacketWriter, int>();
            Builder.SetToString <TPacketWriter, uint>();
            Builder.SetToString <TPacketWriter, long>();
            Builder.SetToString <TPacketWriter, ulong>();
            Builder.SetToString <TPacketWriter, float>();
            Builder.SetToString <TPacketWriter, decimal>();
            Builder.SetToString <TPacketWriter, double>();

            return(Builder);
        }