当前位置: 首页>>代码示例>>C#>>正文


C# Context.GetInstancesAssignableFrom方法代码示例

本文整理汇总了C#中Context.GetInstancesAssignableFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Context.GetInstancesAssignableFrom方法的具体用法?C# Context.GetInstancesAssignableFrom怎么用?C# Context.GetInstancesAssignableFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Context的用法示例。


在下文中一共展示了Context.GetInstancesAssignableFrom方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public void Run(Context context)
        {
            var modules = context.GetInstancesAssignableFrom<INinjectModule>().ToArray();

            foreach (var module in modules)
            {
                Logger.Trace()
                    .Logger<NinjectStarter>()
                    .Message("Register Ninject Module: {0}", module)
                    .Write();
            }

            Logger.Trace()
                .Logger<NinjectStarter>()                    
                .Message("Create Ninject Kernel...")
                .Write();

            var settings = _options.Settings ?? new NinjectSettings();
            var kernel = new StandardKernel(settings, modules);

            if (_options.InitializeKernel != null)
                _options.InitializeKernel(kernel);


            var adaptor = new NinjectAdaptor(kernel);
            context.SetContainer(adaptor);
        }
开发者ID:modulexcite,项目名称:KickStart,代码行数:27,代码来源:NinjectStarter.cs

示例2: Run

        /// <summary>
        /// Runs the application KickStart extension with specified <paramref name="context" />.
        /// </summary>
        /// <param name="context">The KickStart <see cref="Context" /> containing assemblies to scan.</param>
        public void Run(Context context)
        {
            var modules = context.GetInstancesAssignableFrom<Module>();

            var builder = new ContainerBuilder();

            foreach (var module in modules)
            {
                Logger.Trace()
                    .Logger<AutofacStarter>()
                    .Message("Register Autofac Module: {0}", module)
                    .Write();

                builder.RegisterModule(module);
            }

            if (_options.InitializeBuilder != null)
                _options.InitializeBuilder(builder);

            Logger.Trace()
                .Logger<AutofacStarter>()
                .Message("Create Autofac Container...")
                .Write();

            var container = builder.Build(_options.BuildOptions);

            if (_options.InitializeContainer != null)
                _options.InitializeContainer(container);

            var adaptor = new AutofacAdaptor(container);
            context.SetContainer(adaptor);
        }
开发者ID:modulexcite,项目名称:KickStart,代码行数:36,代码来源:AutofacStarter.cs

示例3: Run

        /// <summary>
        /// Runs the application KickStart extension with specified <paramref name="context" />.
        /// </summary>
        /// <param name="context">The KickStart <see cref="Context" /> containing assemblies to scan.</param>
        public void Run(Context context)
        {
            var startupTasks = context.GetInstancesAssignableFrom<IStartupTask>(_options.UseContainer)
                .OrderBy(t => t.Priority)
                .ToList();

            var watch = new Stopwatch();

            foreach (var startupTask in startupTasks)
            {

                Logger.Trace()
                    .Logger<StartupTaskStarter>()
                    .Message("Execute Startup Task; Type: '{0}'", startupTask)
                    .Write();

                watch.Restart();
                startupTask.Run();
                watch.Stop();

                Logger.Trace()
                    .Logger<StartupTaskStarter>()
                    .Message("Complete Startup Task; Type: '{0}', Time: {1} ms", startupTask, watch.ElapsedMilliseconds)
                    .Write();
            }

        }
开发者ID:modulexcite,项目名称:KickStart,代码行数:31,代码来源:StartupTaskStarter.cs

示例4: Run

        /// <summary>
        /// Runs the application KickStart extension with specified <paramref name="context" />.
        /// </summary>
        /// <param name="context">The KickStart <see cref="Context" /> containing assemblies to scan.</param>
        public void Run(Context context)
        {
            var classMaps = context.GetInstancesAssignableFrom<BsonClassMap>();

            foreach (var classMap in classMaps)
            {
                if (BsonClassMap.IsClassMapRegistered(classMap.ClassType))
                    continue;

                Logger.Trace()
                    .Logger<MongoStarter>()
                    .Message("Register MongoDB ClassMap: {0}", classMap)
                    .Write();

                BsonClassMap.RegisterClassMap(classMap);
            }
        }
开发者ID:modulexcite,项目名称:KickStart,代码行数:21,代码来源:MongoStarter.cs

示例5: Run

        public void Run(Context context)
        {
            var modules = context.GetInstancesAssignableFrom<ISimpleInjectorRegistration>();

            var container = new Container();

            foreach (var module in modules)
            {
                Logger.Trace()
                    .Logger<SimpleInjectorStarter>()
                    .Message("Register SimpleInjector Module: {0}", module)
                    .Write();

                module.Register(container);
            }

            if (_options.InitializeContainer != null)
                _options.InitializeContainer(container);

            var adaptor = new SimpleInjectorAdaptor(container);
            context.SetContainer(adaptor);
        }
开发者ID:modulexcite,项目名称:KickStart,代码行数:22,代码来源:SimpleInjectorStarter.cs


注:本文中的Context.GetInstancesAssignableFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。