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

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

There is a newer version: 7.7.0
Show newest version
using System;
using Microsoft.Extensions.DependencyInjection;
using {{packageName}}.{{apiPackage}};

namespace {{packageName}}.{{clientPackage}}
{
    /// 
    /// An IApiFactory interface
    /// 
    {{>visibility}} interface IApiFactory
    {
        /// 
        /// A method to create an IApi of type IResult
        /// 
        /// 
        /// 
        IResult Create() where IResult : IApi;
    }

    /// 
    /// An ApiFactory
    /// 
    {{>visibility}} class ApiFactory : IApiFactory
    {
        /// 
        /// The service provider
        /// 
        public IServiceProvider Services { get; }

        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// 
        public ApiFactory(IServiceProvider services)
        {
            Services = services;
        }

        /// 
        /// A method to create an IApi of type IResult
        /// 
        /// 
        /// 
        public IResult Create() where IResult : IApi
        {
            return Services.GetRequiredService();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy