sparse-intern-71089
12/07/2020, 11:37 PMtall-needle-56640
12/07/2020, 11:47 PMInput
and Output
casts, I can't accomplish what should be easily achievable.tall-needle-56640
12/08/2020, 8:36 PMtall-librarian-49374
12/08/2020, 9:16 PMvar merged = args.SiteConfig
.Apply(c => c.AppSettings.ToOutput())
.Apply(settings =>
Output.All(settings.Select(s => Output.Tuple(s.Name, s.Value))))
.Apply(settings =>
{
var dict = new Dictionary<string, string>(defaultAppSettings);
foreach (var (k, v) in settings)
dict[k] = v;
return dict.Select(kv => new NameValuePairArgs {Name = kv.Key, Value = kv.Value});
});
args.SiteConfig.Apply(s => s.AppSettings = merged);
tall-librarian-49374
12/08/2020, 9:16 PMtall-needle-56640
12/10/2020, 4:16 PMtall-needle-56640
12/10/2020, 4:22 PMInput
/ Output
is pretty slick. But man can it be annoying at the same time. 🙂tall-needle-56640
12/10/2020, 5:42 PMvar value = "someValue";
Input<T> inputValue = value;
var newValue = inputValue.Value;
Assert.Equal(value, newValue);
Maybe Input<T>.Value
is only non-null if it was implicitly cast from type T
class Input<T>
{
public T? Value;
public static implicit operator Input<T>([MaybeNull]T value)
{
Value = value;
return Output.Create(value);
}
}
tall-librarian-49374
12/10/2020, 8:44 PM