Exemple #1
0
        private static void Configure(AsyncGenerator configuration, CancellationTokens config, IFluentProjectCancellationTokenConfiguration fluentConfig)
        {
            if (config.Guards.HasValue)
            {
                fluentConfig.Guards(config.Guards.Value);
            }
            if (config.MethodParameter.Any())
            {
                fluentConfig.ParameterGeneration(CreateParameterGenerationFunction(configuration, config.MethodParameter));
            }
            if (config.WithoutCancellationToken.Any() || config.RequiresCancellationToken.Any())
            {
                foreach (ExecutionPhase value in Enum.GetValues(typeof(ExecutionPhase)))
                {
                    var withoutTokenGroup  = config.WithoutCancellationToken.GroupBy(o => o.ExecutionPhase).FirstOrDefault(o => o.Key == value);
                    var requiresTokenGroup = config.RequiresCancellationToken.GroupBy(o => o.ExecutionPhase).FirstOrDefault(o => o.Key == value);
                    if (withoutTokenGroup != null || requiresTokenGroup != null)
                    {
                        fluentConfig.RequiresCancellationToken(
                            CreateMethodNullablePredicate(configuration,
                                                          withoutTokenGroup?.ToList() ?? new List <MethodFilter>(),
                                                          requiresTokenGroup?.ToList() ?? new List <MethodFilter>()
                                                          ), value);
                    }
                }

                fluentConfig.RequiresCancellationToken(CreateMethodNullablePredicate(configuration,
                                                                                     config.WithoutCancellationToken, config.RequiresCancellationToken));
            }
        }
 private static void Configure(AsyncGenerator configuration, CancellationTokens config, IFluentProjectCancellationTokenConfiguration fluentConfig)
 {
     if (config.Guards.HasValue)
     {
         fluentConfig.Guards(config.Guards.Value);
     }
     if (config.MethodParameter.Any())
     {
         fluentConfig.ParameterGeneration(CreateParameterGenerationFunction(configuration, config.MethodParameter));
     }
     if (config.WithoutCancellationToken.Any() || config.RequiresCancellationToken.Any())
     {
         fluentConfig.RequiresCancellationToken(CreateMethodNullablePredicate(configuration,
                                                                              config.WithoutCancellationToken, config.RequiresCancellationToken));
     }
 }