public static Option <TThree> Three <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour> > union) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour> => union.Match(_ => Option.None <TThree>(), _ => Option.None <TThree>(), Option.Some, _ => Option.None <TThree>());
internal Union(IUnionValue <AdhocUnionDefinition <TOne, TTwo> > value) => _value = value;
public static TUnionType Do <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight> > union, Action <TOne> one, Action <TTwo> two, Action <TThree> three, Action <TFour> four, Action <TFive> five, Action <TSix> six, Action <TSeven> seven, Action <TEight> eight) where TUnionType : struct where TUnionDefinition : notnull, UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight> where TOne : notnull where TTwo : notnull where TThree : notnull where TFour : notnull where TFive : notnull where TSix : notnull where TSeven : notnull where TEight : notnull { if (one == null) { throw new ArgumentNullException(nameof(one)); } if (two == null) { throw new ArgumentNullException(nameof(two)); } if (three == null) { throw new ArgumentNullException(nameof(three)); } if (four == null) { throw new ArgumentNullException(nameof(four)); } if (five == null) { throw new ArgumentNullException(nameof(five)); } if (six == null) { throw new ArgumentNullException(nameof(six)); } if (seven == null) { throw new ArgumentNullException(nameof(seven)); } if (eight == null) { throw new ArgumentNullException(nameof(eight)); } union.Match(value => { one.Invoke(value); return(false); }, value => { two.Invoke(value); return(false); }, value => { three.Invoke(value); return(false); }, value => { four.Invoke(value); return(false); }, value => { five.Invoke(value); return(false); }, value => { six.Invoke(value); return(false); }, value => { seven.Invoke(value); return(false); }, value => { eight.Invoke(value); return(false); }); return(union.AsUnion()); }
public static void Apply <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight> > union, Action <TOne> one, Action <TTwo> two, Action <TThree> three, Action <TFour> four, Action <TFive> five, Action <TSix> six, Action <TSeven> seven, Action <TEight> eight) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight> => union.Do(one, two, three, four, five, six, seven, eight);
public static TUnionType AsUnion <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight> > union) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight> => ((UnionValue <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight>)union).GetUnion();
internal Union(IUnionValue <TUnionDefinition> value) => _value = value;
public static void Apply <TUnionType, TUnionDefinition, TOne>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne> > union, Action <TOne> one) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase <TUnionType, TUnionDefinition, TOne> => union.Do(one);
public static Task ApplyAsync<TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour>(this IUnionValue<UnionDefinitionBase<TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour>> union, Func<TOne, Task> one, Func<TTwo, Task> two, Func<TThree, Task> three, Func<TFour, Task> four) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase<TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour> => union.Match(one, two, three, four);
public static Task ApplyAsync<TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven>(this IUnionValue<UnionDefinitionBase<TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven>> union, Func<TOne, Task> one, Func<TTwo, Task> two, Func<TThree, Task> three, Func<TFour, Task> four, Func<TFive, Task> five, Func<TSix, Task> six, Func<TSeven, Task> seven) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase<TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven> => union.Match(one, two, three, four, five, six, seven);
public static Task <TResult> MatchAsync <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TResult>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven> > union, Func <TOne, Task <TResult> > one, Func <TTwo, Task <TResult> > two, Func <TThree, Task <TResult> > three, Func <TFour, Task <TResult> > four, Func <TFive, Task <TResult> > five, Func <TSix, Task <TResult> > six, Func <TSeven, Task <TResult> > seven) where TUnionType : struct where TUnionDefinition : notnull, UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven> where TOne : notnull where TTwo : notnull where TThree : notnull where TFour : notnull where TFive : notnull where TSix : notnull where TSeven : notnull => union.Match(one, two, three, four, five, six, seven);
public static Task ApplyAsync<TUnionType, TUnionDefinition, TOne>(this IUnionValue<UnionDefinitionBase<TUnionType, TUnionDefinition, TOne>> union, Func<TOne, Task> one) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase<TUnionType, TUnionDefinition, TOne> => union.Match(one);
public static Task <TResult> MatchAsync <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TResult>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour> > union, Func <TOne, Task <TResult> > one, Func <TTwo, Task <TResult> > two, Func <TThree, Task <TResult> > three, Func <TFour, Task <TResult> > four) where TUnionType : struct where TUnionDefinition : notnull, UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour> where TOne : notnull where TTwo : notnull where TThree : notnull where TFour : notnull => union.Match(one, two, three, four);
public static Task <TResult> MatchAsync <TUnionType, TUnionDefinition, TOne, TResult>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne> > union, Func <TOne, Task <TResult> > one) where TUnionType : struct where TUnionDefinition : notnull, UnionDefinitionBase <TUnionType, TUnionDefinition, TOne> where TOne : notnull => union.Match(one);
public static TResult Match <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TResult>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix> > union, Func <TOne, TResult> one, Func <TTwo, TResult> two, Func <TThree, TResult> three, Func <TFour, TResult> four, Func <TFive, TResult> five, Func <TSix, TResult> six) where TUnionType : struct where TUnionDefinition : notnull, UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix> where TOne : notnull where TTwo : notnull where TThree : notnull where TFour : notnull where TFive : notnull where TSix : notnull { if (one == null) { throw new ArgumentNullException(nameof(one)); } if (two == null) { throw new ArgumentNullException(nameof(two)); } if (three == null) { throw new ArgumentNullException(nameof(three)); } if (four == null) { throw new ArgumentNullException(nameof(four)); } if (five == null) { throw new ArgumentNullException(nameof(five)); } if (six == null) { throw new ArgumentNullException(nameof(six)); } if (union is UnionValue <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix> storage) { switch (storage.State) { case 0: return(one.Invoke(storage.One)); case 1: return(two.Invoke(storage.Two)); case 2: return(three.Invoke(storage.Three)); case 3: return(four.Invoke(storage.Four)); case 4: return(five.Invoke(storage.Five)); case 5: return(six.Invoke(storage.Six)); } } throw new UnionInvalidMatchException(); }
public static TUnionType AsUnion <TUnionType, TUnionDefinition, TOne, TTwo>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo> > union) where TUnionType : struct where TUnionDefinition : notnull, UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo> where TOne : notnull where TTwo : notnull => ((UnionValue <TUnionType, TUnionDefinition, TOne, TTwo>)union).GetUnion();
public static async Task<TUnionType> DoAsync<TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour>(this IUnionValue<UnionDefinitionBase<TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour>> union, Func<TOne, Task> one, Func<TTwo, Task> two, Func<TThree, Task> three, Func<TFour, Task> four) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase<TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour> { await union.Match(one, two, three, four); return union.AsUnion(); }
public static TUnionType AsUnion <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix> > union) where TUnionType : struct where TUnionDefinition : notnull, UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix> where TOne : notnull where TTwo : notnull where TThree : notnull where TFour : notnull where TFive : notnull where TSix : notnull => ((UnionValue <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix>)union).GetUnion();
public static async Task<TUnionType> DoAsync<TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven>(this IUnionValue<UnionDefinitionBase<TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven>> union, Func<TOne, Task> one, Func<TTwo, Task> two, Func<TThree, Task> three, Func<TFour, Task> four, Func<TFive, Task> five, Func<TSix, Task> six, Func<TSeven, Task> seven) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase<TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven> { await union.Match(one, two, three, four, five, six, seven); return union.AsUnion(); }
public static void Serialize(SerializationInfo info, IUnionValue unionValue) { info.AddValue(StateName, (byte)unionValue.State); info.AddValue(ValueName, unionValue.Value); }
public static TResult Match <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight, TResult>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight> > union, Func <TOne, TResult> one, Func <TTwo, TResult> two, Func <TThree, TResult> three, Func <TFour, TResult> four, Func <TFive, TResult> five, Func <TSix, TResult> six, Func <TSeven, TResult> seven, Func <TEight, TResult> eight) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight> { if (one == null) { throw new ArgumentNullException(nameof(one)); } if (two == null) { throw new ArgumentNullException(nameof(two)); } if (three == null) { throw new ArgumentNullException(nameof(three)); } if (four == null) { throw new ArgumentNullException(nameof(four)); } if (five == null) { throw new ArgumentNullException(nameof(five)); } if (six == null) { throw new ArgumentNullException(nameof(six)); } if (seven == null) { throw new ArgumentNullException(nameof(seven)); } if (eight == null) { throw new ArgumentNullException(nameof(eight)); } if (union is UnionValue <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight> storage) { switch (storage.State) { case 0: return(one.Invoke(storage.One)); case 1: return(two.Invoke(storage.Two)); case 2: return(three.Invoke(storage.Three)); case 3: return(four.Invoke(storage.Four)); case 4: return(five.Invoke(storage.Five)); case 5: return(six.Invoke(storage.Six)); case 6: return(seven.Invoke(storage.Seven)); case 7: return(eight.Invoke(storage.Eight)); } } throw new UnionInvalidMatchException(); }
public static void Apply <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive> > union, Action <TOne> one, Action <TTwo> two, Action <TThree> three, Action <TFour> four, Action <TFive> five) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive> => union.Do(one, two, three, four, five);
public static Task <TResult> MatchAsync <TUnionType, TUnionDefinition, TOne, TTwo, TResult>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo> > union, Func <TOne, Task <TResult> > one, Func <TTwo, Task <TResult> > two) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo> => union.Match(one, two);
public static TUnionType Do <TUnionType, TUnionDefinition, TOne, TTwo, TThree>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree> > union, Action <TOne> one, Action <TTwo> two, Action <TThree> three) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree> { if (one == null) { throw new ArgumentNullException(nameof(one)); } if (two == null) { throw new ArgumentNullException(nameof(two)); } if (three == null) { throw new ArgumentNullException(nameof(three)); } union.Match(value => { one.Invoke(value); return(false); }, value => { two.Invoke(value); return(false); }, value => { three.Invoke(value); return(false); }); return(union.AsUnion()); }
public static Task <TResult> MatchAsync <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TResult>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive> > union, Func <TOne, Task <TResult> > one, Func <TTwo, Task <TResult> > two, Func <TThree, Task <TResult> > three, Func <TFour, Task <TResult> > four, Func <TFive, Task <TResult> > five) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive> => union.Match(one, two, three, four, five);
public static TUnionType AsUnion <TUnionType, TUnionDefinition, TOne>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne> > union) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase <TUnionType, TUnionDefinition, TOne> => ((UnionValue <TUnionType, TUnionDefinition, TOne>)union).GetUnion();
public static Task <TResult> MatchAsync <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight, TResult>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight> > union, Func <TOne, Task <TResult> > one, Func <TTwo, Task <TResult> > two, Func <TThree, Task <TResult> > three, Func <TFour, Task <TResult> > four, Func <TFive, Task <TResult> > five, Func <TSix, Task <TResult> > six, Func <TSeven, Task <TResult> > seven, Func <TEight, Task <TResult> > eight) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight> => union.Match(one, two, three, four, five, six, seven, eight);
public static TUnionType Do <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive> > union, Action <TOne> one, Action <TTwo> two, Action <TThree> three, Action <TFour> four, Action <TFive> five) where TUnionType : struct where TUnionDefinition : notnull, UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive> where TOne : notnull where TTwo : notnull where TThree : notnull where TFour : notnull where TFive : notnull { if (one == null) { throw new ArgumentNullException(nameof(one)); } if (two == null) { throw new ArgumentNullException(nameof(two)); } if (three == null) { throw new ArgumentNullException(nameof(three)); } if (four == null) { throw new ArgumentNullException(nameof(four)); } if (five == null) { throw new ArgumentNullException(nameof(five)); } union.Match(value => { one.Invoke(value); return(false); }, value => { two.Invoke(value); return(false); }, value => { three.Invoke(value); return(false); }, value => { four.Invoke(value); return(false); }, value => { five.Invoke(value); return(false); }); return(union.AsUnion()); }
public static TResult Match <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TResult>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree> > union, Func <TOne, TResult> one, Func <TTwo, TResult> two, Func <TThree, TResult> three) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree> { if (one == null) { throw new ArgumentNullException(nameof(one)); } if (two == null) { throw new ArgumentNullException(nameof(two)); } if (three == null) { throw new ArgumentNullException(nameof(three)); } if (union is UnionValue <TUnionType, TUnionDefinition, TOne, TTwo, TThree> storage) { switch (storage.State) { case 0: return(one.Invoke(storage.One)); case 1: return(two.Invoke(storage.Two)); case 2: return(three.Invoke(storage.Three)); } } throw new UnionInvalidMatchException(); }
public static void Apply <TUnionType, TUnionDefinition, TOne, TTwo>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo> > union, Action <TOne> one, Action <TTwo> two) where TUnionType : struct where TUnionDefinition : notnull, UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo> where TOne : notnull where TTwo : notnull => union.Do(one, two);
public static Option <TEight> Eight <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight>(this IUnionValue <UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight> > union) where TUnionType : struct where TUnionDefinition : UnionDefinitionBase <TUnionType, TUnionDefinition, TOne, TTwo, TThree, TFour, TFive, TSix, TSeven, TEight> => union.Match(_ => Option.None <TEight>(), _ => Option.None <TEight>(), _ => Option.None <TEight>(), _ => Option.None <TEight>(), _ => Option.None <TEight>(), _ => Option.None <TEight>(), _ => Option.None <TEight>(), Option.Some);