private static void ConfigureServices(IServiceCollection services, IConfiguration config) { var assemblies = new[] { Assembly.GetExecutingAssembly() }; BindingAttribute.ConfigureBindings(services, assemblies); OptionsAttribute.ConfigureOptions(services, config, assemblies); FactoryAttribute.ConfigureFactories(services, assemblies); services.ConfigureApiClient(); services.AddSingleton(config); services.AddSingleton <IFileSystem, FileSystem>(); services.AddDbContext <ManagementDbContext>(options => { options.UseSqlite("Data Source=disunity.db"); }, ServiceLifetime.Singleton); }
private static void BindServices(IServiceCollection services, IConfigurationRoot configuration) { Console.WriteLine("Binding services..."); OptionsAttribute.ConfigureOptions(services, configuration); BindingAttribute.ConfigureBindings(services); FactoryAttribute.ConfigureFactories(services); services // bind third-party services (can't add binding attributes to classes we don't control) .AddLogging(builder => builder.AddConsole()) .AddSingleton(configuration) .AddSingleton(new Serializer()) .AddSingleton <ISlugHelper, SlugHelper>() .AddSingleton <CommandService>(); }
public static void ConfigureAttributes(this IServiceCollection services) { BindingAttribute.ConfigureBindings(services); FactoryAttribute.ConfigureFactories(services); }