本文整理汇总了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);
}
示例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);
}
示例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();
}
}
示例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);
}
}
示例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);
}