本文整理汇总了C#中Container.AssertConfigurationIsValid方法的典型用法代码示例。如果您正苦于以下问题:C# Container.AssertConfigurationIsValid方法的具体用法?C# Container.AssertConfigurationIsValid怎么用?C# Container.AssertConfigurationIsValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Container
的用法示例。
在下文中一共展示了Container.AssertConfigurationIsValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compose
public static IDependencyInjectionContainer Compose()
{
// Create the DI container
var container = new Container();
container.Configure(expression =>
{
expression.For<DomainService<Course>>().HybridHttpOrThreadLocalScoped().Use<CourseDomainSource>();
expression.For<DomainService<Lead>>().HybridHttpOrThreadLocalScoped().Use<LeadDomainService>();
expression.For<DomainService<User>>().HybridHttpOrThreadLocalScoped().Use<UserDomainService>();
expression.For<DomainService<Country>>().HybridHttpOrThreadLocalScoped().Use<CountryDomainService>();
expression.For<DataProvider<Course>>().HybridHttpOrThreadLocalScoped().Use<CourseDataProvider>();
expression.For<DataProvider<Lead>>().HybridHttpOrThreadLocalScoped().Use<LeadDataProvider>();
expression.For<DataProvider<User>>().HybridHttpOrThreadLocalScoped().Use<UserDataProvider>();
expression.For<DataProvider<Country>>().HybridHttpOrThreadLocalScoped().Use<CountryDataProvider>();
expression.Scan(scanner =>
{
scanner.TheCallingAssembly();
scanner.WithDefaultConventions();
});
});
// Setup configuration of DI
container.Configure(r => r.AddRegistry<MvcSiteMapProviderRegistry>());
#if DEBUG
container.AssertConfigurationIsValid();
#endif
// Return our DI container wrapper instance
return new StructureMapDependencyInjectionContainer(container);
}
示例2: PipelineTests
public PipelineTests()
{
var container = new Container(c =>
{
c.Scan(s =>
{
s.AssemblyContainingType(typeof(RequestPipelineHandler<>));
s.ConnectImplementationsToTypesClosing(typeof(IHandle<>));
s.ConnectImplementationsToTypesClosing(typeof(IHandle<,>));
s.ConnectImplementationsToTypesClosing(typeof(IHandleAsync<>));
s.ConnectImplementationsToTypesClosing(typeof(IHandleAsync<,>));
s.TheCallingAssembly();
s.WithDefaultConventions();
s.AddAllTypesOf(typeof(IPreRequestHandler<>));
s.AddAllTypesOf(typeof(IPostRequestHandler<>));
s.AddAllTypesOf(typeof(IPostRequestResponseHandler<,>));
});
c.For(typeof(IHandle<>)).DecorateAllWith(typeof(RequestPipelineHandler<>));
c.For(typeof(IHandle<,>)).DecorateAllWith(typeof(RequestResponsePipelineHandler<,>));
c.For(typeof(IHandleAsync<>)).DecorateAllWith(typeof(AsyncRequestPipelineHandler<>));
c.For(typeof(IHandleAsync<,>)).DecorateAllWith(typeof(AsyncRequestResponsePipelineHandler<,>));
});
container.AssertConfigurationIsValid();
_dispatcher = AppDispatcherFactory.Create(app => app.UseCommonServiceLocator(new StructureMapServiceLocator(container)));
}
示例3: CreateContainer
public static Container CreateContainer()
{
var container = new Container(
x =>
{
x.For<BotFactory>().Singleton().Use<BotFactoryImpl>();
x.For<Bot>().HybridHttpOrThreadLocalScoped().Use<ClassicIrcBot>();
x.For<DataSource>().HybridHttpOrThreadLocalScoped().Use<BotDataSource>();
x.For<DataSourceConnection>().HybridHttpOrThreadLocalScoped().Use<XMLDataSourceConnection>();
x.For<PrivateMessageParser>().Use<PrivateMessageParserImpl>();
x.For<Connection>().HybridHttpOrThreadLocalScoped().Use<IrcConnection>();
x.For<Handler>().Singleton().Use<BotHandler>();
x.For<PluginWatcher>().Singleton().Use<FileSystemPluginWatcher>();
x.For<PluginLoader>().Singleton().Use<PluginLoaderImpl>();
x.AddRegistry<CommandManagementRegistry>();
x.AddRegistry<CommandRegistry>();
x.AddRegistry<HandlerRegistry>();
x.AddRegistry<EventRegistry>();
x.AddRegistry<PluginRegistry>();
});
container.AssertConfigurationIsValid();
return container;
}
示例4: Initialize
public static IContainer Initialize()
{
var container = new Container(c => c.AddRegistry<DefaultRegistry>());
GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerActivator), new ServiceActivator(container));
container.AssertConfigurationIsValid();
return container;
}
示例5: RavenDBRegistyClassIsValid
public void RavenDBRegistyClassIsValid()
{
using (var container = new Container(cfg => cfg.AddRegistry(new RavenDbRegistry("RavenDB"))))
{
container.AssertConfigurationIsValid();
}
}
示例6: happy_path_with_validation_method
public void happy_path_with_validation_method()
{
var container =
new Container(x => { x.For<IWidget>().Use<ValidatingFailureWidget>().Ctor<bool>("fails").Is(false); });
container.AssertConfigurationIsValid();
}
示例7: happy_path_with_build_plans_all_good
public void happy_path_with_build_plans_all_good()
{
var container = new Container(x => x.For<IWidget>().Use<NamedWidget>().Ctor<string>().Is("Marshall"));
// SAMPLE: container.AssertConfigurationIsValid
container.AssertConfigurationIsValid();
// ENDSAMPLE
}
示例8: assert_bootstrapper_is_valid
public void assert_bootstrapper_is_valid()
{
using (var container = new Container())
{
container.AssertConfigurationIsValid();
}
}
示例9: VerifyValidConfiguration
public void VerifyValidConfiguration()
{
var container = new Container(x =>
{
x.For<IService>().Use<Service>();
});
container.AssertConfigurationIsValid();
}
示例10: VerifyInvalidConfiguration
public void VerifyInvalidConfiguration()
{
var container = new Container(x =>
{
x.For<IService>().Use<BrokenService>();
});
Assert.Throws<StructureMapConfigurationException>(
() => container.AssertConfigurationIsValid());
}
示例11: MissingRequiredConstructorArgument
public void MissingRequiredConstructorArgument()
{
var container = new Container(x =>
{
x.For<IService>().Use<ServiceWithCtorArg>();
});
Assert.Throws<StructureMapConfigurationException>(
() => container.AssertConfigurationIsValid());
}
示例12: sad_path_with_validation_method
public void sad_path_with_validation_method()
{
var container =
new Container(x => { x.For<IWidget>().Use<ValidatingFailureWidget>().Ctor<bool>("fails").Is(true); });
var ex =
Exception<StructureMapConfigurationException>.ShouldBeThrownBy(
() => { container.AssertConfigurationIsValid(); });
ex.Title.ShouldBe("StructureMap Failures: 0 Build/Configuration Failures and 1 Validation Errors");
ex.Context.ShouldContain("Validation Error in Method Validate");
}
示例13: sad_path_with_an_invalid_build_plan
public void sad_path_with_an_invalid_build_plan()
{
var container = new Container(x => { x.For<IWidget>().Use<NamedWidget>(); });
var ex =
Exception<StructureMapConfigurationException>.ShouldBeThrownBy(
() => { container.AssertConfigurationIsValid(); });
ex.Title.ShouldBe("StructureMap Failures: 1 Build/Configuration Failures and 0 Validation Errors");
ex.Context.ShouldContain(
"Unable to create a build plan for concrete type StructureMap.Testing.Diagnostics.NamedWidget");
}
示例14: CanSetupContainer
public void CanSetupContainer()
{
//arrange
var container = new Container();
var registrar = new StructuremapRegistrar();
//act
registrar.ConfigureDependencies(container, false);
//assert
container.AssertConfigurationIsValid();
}
示例15: CanSetupContainer
public void CanSetupContainer()
{
//arrange
var container = new Container();
var registrar = new StructuremapRegistrar();
//act
registrar.ConfigureDependencies(container);
//assert
container.AssertConfigurationIsValid();
//Log.Info(container.WhatDoIHave());
}