csharp.libraries.generichost.ApiFactory.mustache Maven / Gradle / Ivy
The 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 - 2025 Weber Informatics LLC | Privacy Policy