本文整理汇总了C#中IContainer.RegisterTransient方法的典型用法代码示例。如果您正苦于以下问题:C# IContainer.RegisterTransient方法的具体用法?C# IContainer.RegisterTransient怎么用?C# IContainer.RegisterTransient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContainer
的用法示例。
在下文中一共展示了IContainer.RegisterTransient方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterServices
public void RegisterServices(IContainer container, CompositionRootSettings settings)
{
// Registers the default implementations
container.RegisterLazySingleton<ILogger, EmptyLogger>();
container.RegisterLazySingleton<ILoggerSerializer, JsonLoggerSerializer>();
container.RegisterLazySingleton<IStopwatch, DefaultStopwatch>();
container.RegisterLazySingleton<IValidator, DataAnnotationsValidator>();
container.RegisterLazySingleton<IClock, SystemClock>();
container.RegisterLazySingleton<IAttributeFinder, AttributeFinder>();
if (settings.ApplicationTypes == null) return;
// Registers all the implementations from the application
foreach (var type in settings.ApplicationTypes)
{
var interfaces = ExcludeEventHandlersInterfaces(type).ToList();
foreach (var i in interfaces)
container.RegisterTransient(i, type);
}
}
示例2: RegisterServices
public void RegisterServices(IContainer container, CompositionRootSettings settings)
{
Guard.ArgumentIsNotNull(settings.ApplicationAssemblies, nameof(settings.ApplicationAssemblies));
container.RegisterSingleton<ICommandDispatcher, CommandDispatcher>();
container.RegisterTransient(typeof (ICommandHandler<>), settings.ApplicationAssemblies);
container.RegisterScoped<ICommandPostAction, CommandPostAction>();
container.RegisterDecoratorTransient(
typeof (ICommandHandler<>),
typeof (DomainEventDispatcherDecorator<>));
container.RegisterDecoratorTransient(
typeof (ICommandHandler<>),
typeof (CommandTransactionDecorator<>));
container.RegisterDecoratorTransient(
typeof (ICommandHandler<>),
typeof (CommandPostActionDecorator<>));
container.RegisterDecoratorSingleton(
typeof (ICommandHandler<>),
typeof (ApplicationEventDispatcherDecorator<>));
container.RegisterDecoratorSingleton(
typeof (ICommandHandler<>),
typeof (CommandValidationDecorator<>));
container.RegisterDecoratorSingleton(
typeof (ICommandHandler<>),
typeof (CommandLoggerDecorator<>));
container.RegisterDecoratorSingleton(
typeof(ICommandHandler<>),
typeof(CommandLifetimeScopeDecorator<>));
}
示例3: Register
public static void Register(IContainer container)
{
container.RegisterTransient<ITestFrameworkAdapter, MSTestAdapter>();
}