Beispiel #1
0
        public static double ReadDouble(this IPv2ServerParamsInterface src, Pv2ParamType param)
        {
            if (param is not Pv2DoubleParamType uintType)
            {
                throw new Exception($"Wrong type: want {nameof(Pv2DoubleParamType)}. Got {param.GetType().Name}");
            }
            var paramResult = src.Read(param);

            return(uintType.GetValue(paramResult));
        }
Beispiel #2
0
        public static async Task <double> WriteDouble(this IPv2ClientParamsInterface src, Pv2ParamType param,
                                                      double value, CancellationToken cancel = default)
        {
            if (param is not Pv2DoubleParamType uintType)
            {
                throw new Exception($"Wrong type: want {nameof(Pv2DoubleParamType)}. Got {param.GetType().Name}");
            }
            var result = await src.Write(param, (_, val) => uintType.SetValue(val, value), cancel)
                         .ConfigureAwait(false);

            return(uintType.GetValue(result));
        }
Beispiel #3
0
        public static string ReadEnum(this IPv2ClientParamsInterface src, Pv2ParamType param)
        {
            if (param is not Pv2EnumParamType type)
            {
                throw new Exception($"Wrong type: want {nameof(Pv2EnumParamType)}. Got {param.GetType().Name}");
            }
            var item = src.Read(type);

            return(type.GetValue(item));
        }
Beispiel #4
0
 public static void WriteDouble(this IPv2ServerParamsInterface src, Pv2ParamType param, double value)
 {
     if (param is not Pv2DoubleParamType uintType)
     {
         throw new Exception($"Wrong type: want {nameof(Pv2DoubleParamType)}. Got {param.GetType().Name}");
     }
     src.Write(param, (_, v) => uintType.SetValue(v, value));
 }
Beispiel #5
0
 public static void WriteEnum(this IPv2ServerParamsInterface src, Pv2ParamType param, string value)
 {
     if (param is not Pv2EnumParamType type)
     {
         throw new Exception($"Wrong type: want {nameof(Pv2EnumParamType)}. Got {param.GetType().Name}");
     }
     src.Write(param, (_, v) => type.SetValue(v, value));
 }