コード例 #1
0
ファイル: Startup.cs プロジェクト: zz9527/CodeDi
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var options = new CodeDiOptions();

            Configuration.Bind("CodeDiOptions", options);
            services.AddCoreDi(options);
            services.AddMvc();
        }
コード例 #2
0
ファイル: CodeDiTest.cs プロジェクト: zz9527/CodeDi
        public void ParseOptionsToCodeDi()
        {
            var options = new CodeDiOptions()
            {
                DefaultServiceLifetime  = ServiceLifetime.Scoped,
                AssemblyNames           = new [] { "*CodeDi" },
                AssemblyPaths           = new [] { "C:\\MyBox\\Github\\CodeDI\\CodeDI\\bin\\Debug\\netstandard2.0" },
                IgnoreAssemblies        = new [] { "*Test" },
                IncludeSystemAssemblies = false,
                IgnoreInterface         = new [] { "*Say" },
                InterfaceMappings       = new Dictionary <string, string>()
                {
                    { "*Say", "*English" }
                },
                ServiceLifeTimeMappings = new Dictionary <string, ServiceLifetime>()
                {
                    { "*Say", ServiceLifetime.Singleton }
                }
            };
            var json = JsonConvert.SerializeObject(options);

            Console.WriteLine(json);
        }