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)); }
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)); }
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)); }
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)); }
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)); }