All Downloads are FREE. Search and download functionalities are using the official Maven repository.

csharp.libraries.generichost.IHostBuilderExtensions.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
{{>partial_header}}
{{#nrt}}
#nullable enable

{{/nrt}}
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using {{packageName}}.{{clientPackage}};

namespace {{packageName}}.Extensions
{
    /// 
    /// Extension methods for IHostBuilder
    /// 
    {{>visibility}} static class IHostBuilderExtensions
    {
        {{^hasAuthMethods}}
        /// 
        /// Add the api to your host builder.
        /// 
        /// 
        public static IHostBuilder Configure{{apiName}}(this IHostBuilder builder)
        {
            builder.ConfigureServices((context, services) => 
            {
                HostConfiguration config = new HostConfiguration(services);

                IServiceCollectionExtensions.Add{{apiName}}(services, config);
            });

            return builder;
        }

        {{/hasAuthMethods}}
        /// 
        /// Add the api to your host builder.
        /// 
        /// 
        /// 
        public static IHostBuilder Configure{{apiName}}(this IHostBuilder builder, Action options)
        {
            builder.ConfigureServices((context, services) => 
            {
                HostConfiguration config = new HostConfiguration(services);

                options(context, services, config);

                IServiceCollectionExtensions.Add{{apiName}}(services, config);
            });

            return builder;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy