Exemplo n.º 1
0
    public static IResolverCompilerBuilder AddParameter <T>(
        this IResolverCompilerBuilder builder,
        Expression <Func <IResolverContext, T> > expression,
        Func <ParameterInfo, bool>?canHandle = null)
    {
        if (builder is null)
        {
            throw new ArgumentNullException(nameof(builder));
        }

        if (expression is null)
        {
            throw new ArgumentNullException(nameof(expression));
        }

        if (canHandle is null)
        {
            builder.RequestExecutorBuilder.Services.AddParameterExpressionBuilder(
                _ => new CustomParameterExpressionBuilder <T>(expression));
        }
        else
        {
            builder.RequestExecutorBuilder.Services.AddParameterExpressionBuilder(
                _ => new CustomParameterExpressionBuilder <T>(expression, canHandle));
        }
        return(builder);
    }
Exemplo n.º 2
0
    public static IResolverCompilerBuilder AddService <TService>(
        this IResolverCompilerBuilder builder)
        where TService : class
    {
        if (builder is null)
        {
            throw new ArgumentNullException(nameof(builder));
        }

        builder.RequestExecutorBuilder.Services.AddSingleton <IParameterExpressionBuilder>(
            new CustomServiceParameterExpressionBuilder <TService>());
        return(builder);
    }
Exemplo n.º 3
0
        /// <summary>
        /// Marks types as well-known services that no longer need the
        /// <see cref="ServiceAttribute"/> annotation.
        /// </summary>
        /// <param name="builder">
        /// The <see cref="IResolverCompilerBuilder"/>.
        /// </param>
        /// <typeparam name="TService">
        /// The well-known service type.
        /// </typeparam>
        /// <returns>
        /// An <see cref="IResolverCompilerBuilder"/> that can be used to configure to
        /// chain in more configuration.
        /// </returns>
        public static IResolverCompilerBuilder AddService <TService>(
            this IResolverCompilerBuilder builder)
        {
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.RequestExecutorBuilder.Services
            .TryAddParameterExpressionBuilder <
                CustomServiceParameterExpressionBuilder <TService> >();
            return(builder);
        }