public static bool ReadBool(this IPv2ClientParamsInterface src, Pv2ParamType param) { if (param is not Pv2BoolParamType type) { throw new Exception($"Wrong type: want {nameof(Pv2BoolParamType)}. Got {param.GetType().Name}"); } var item = src.Read(param); return(type.GetValue(item)); }
public static async Task <bool> WriteBool(this IPv2ClientParamsInterface src, Pv2ParamType param, bool value, CancellationToken cancel = default) { if (param is not Pv2BoolParamType type) { throw new Exception($"Wrong type: want {nameof(Pv2BoolParamType)}. Got {param.GetType().Name}"); } var result = await src.Write(param, (_, val) => type.SetValue(val, value), cancel).ConfigureAwait(false); return(type.GetValue(result)); }
public static void WriteBool(this IPv2ServerParamsInterface src, Pv2ParamType param, bool value) { if (param is not Pv2BoolParamType type) { throw new Exception($"Wrong type: want {nameof(Pv2BoolParamType)}. Got {param.GetType().Name}"); } src.Write(param, (_, v) => type.SetValue(v, value)); }