예제 #1
0
        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);
        }
예제 #2
0
        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>();
        }
예제 #3
0
 public static void ConfigureAttributes(this IServiceCollection services)
 {
     BindingAttribute.ConfigureBindings(services);
     FactoryAttribute.ConfigureFactories(services);
 }