Example #1
0
 protected override void Configure(IObjectTypeDescriptor <ContestComboDetail> descriptor)
 {
     descriptor.Field(x => x.UseBefore)
     .Description("A list of moves to use before this move.")
     .Type <ListType <MoveType> >()
     .Resolver((ctx, token) =>
     {
         var resolver = ctx.Service <MoveResolver>();
         return(MonadMaybe.Lift(ctx.Parent <ContestComboDetail>())
                .Select(x => x.UseBefore)
                .Select(moves => moves.Select(move => resolver.GetMoveAsync(move.Name, token)))
                .Match(Task.WhenAll, Task.FromResult <Move[]>(default)));
Example #2
0
 /// <summary>
 /// Projects the wrapped value into a new one and wraps it.
 /// </summary>
 /// <typeparam name="TSource">The type of the wrapped value.</typeparam>
 /// <typeparam name="TResult">The type to project the value into.</typeparam>
 /// <param name="source">The wrapper.</param>
 /// <param name="project">A transform function to apply on the wrapped value.</param>
 /// <returns>The projection of the wrapped value in a wrapper.</returns>
 public static Maybe <TResult> Select <TSource, TResult>(this Maybe <TSource> source, Func <TSource, TResult> project)
 => source.Bind(val => Maybe.Lift(project(val)));
Example #3
0
 /// <summary>
 /// Maps the wrapped value into another wrapped value.
 /// </summary>
 /// <typeparam name="TResult">The type of the result of the mapping.</typeparam>
 /// <param name="mapFn">The mapping function. Should not throw exceptions.</param>
 /// <returns>The wrapped mapped value.</returns>
 public Maybe <TResult> Map <TResult>(Func <T, TResult> mapFn) => this.Bind(val => Maybe.Lift(mapFn(val)));