本文整理汇总了C#中Funq.Container.RegisterValidators方法的典型用法代码示例。如果您正苦于以下问题:C# Container.RegisterValidators方法的具体用法?C# Container.RegisterValidators怎么用?C# Container.RegisterValidators使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Funq.Container
的用法示例。
在下文中一共展示了Container.RegisterValidators方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public override void Configure(Container container)
{
Plugins.Add(new SwaggerFeature());
Plugins.Add(new RazorFormat());
Plugins.Add(new RequestLogsFeature());
Plugins.Add(new PostmanFeature());
Plugins.Add(new CorsFeature());
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(ContactsServices).Assembly);
Plugins.Add(new AutoQueryFeature());
container.Register<IDbConnectionFactory>(
c => new OrmLiteConnectionFactory("~/db.sqlite".MapHostAbsolutePath(), SqliteDialect.Provider) {
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
});
using (var db = container.Resolve<IDbConnectionFactory>().Open())
{
db.DropAndCreateTable<Email>();
db.DropAndCreateTable<Contact>();
ContactsServices.AddCustomers(db);
}
UseDbEmailer(container);
//UseSmtpEmailer(container); //Uncomment to use SMTP instead
//ConfigureRabbitMqServer(container); //Uncomment to start accepting requests via Rabbit MQ
}
示例2: Configure
public override void Configure(Container container)
{
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(AppHost).Assembly);
container.RegisterAutoWired<BicyleRepository>();
}
示例3: Configure
public override void Configure(Container container)
{
//ASP.NET MVC integration
ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
SetConfig(CreateEndpointHostConfig());
JsConfig.EmitCamelCaseNames = true;
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(AppHost).Assembly);
container.Register<ICacheClient>(new MemoryCacheClient());
container.RegisterAutoWired<BicyleRepository>();
Plugins.Add(new AuthFeature(
() => new AuthUserSession(),
new IAuthProvider[] {
new CredentialsAuthProvider()
}));
var userAuthRepository = new InMemoryAuthRepository();
userAuthRepository.CreateUserAuth(new UserAuth { Email = "[email protected]", DisplayName= "Admin User"}, "admin");
container.Register<IUserAuthRepository>(userAuthRepository);
}
示例4: Configure
public override void Configure(Container container)
{
Plugins.Add(new SwaggerFeature());
Plugins.Add(new RazorFormat());
Plugins.Add(new RequestLogsFeature());
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(ContactsServices).Assembly);
container.Register<IDbConnectionFactory>(
c => new OrmLiteConnectionFactory("db.sqlite", SqliteDialect.Provider) {
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
});
using (var db = container.Resolve<IDbConnectionFactory>().Open())
{
db.DropAndCreateTable<Email>();
db.DropAndCreateTable<Contact>();
db.Insert(new Contact { Name = "Kurt Cobain", Email = "[email protected]", Age = 27 });
db.Insert(new Contact { Name = "Jimi Hendrix", Email = "[email protected]", Age = 27 });
db.Insert(new Contact { Name = "Michael Jackson", Email = "[email protected]", Age = 50 });
}
UseDbEmailer(container);
//UseSmtpEmailer(container); //Uncomment to use SMTP instead
//ConfigureRabbitMqServer(container); //Uncomment to start accepting requests via Rabbit MQ
}
示例5: Configure
public override void Configure(Container container)
{
if (EnableRazor)
Plugins.Add(new RazorFormat());
Plugins.Add(new SwaggerFeature());
Plugins.Add(new RequestInfoFeature());
Plugins.Add(new RequestLogsFeature());
Plugins.Add(new ServerEventsFeature());
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(AutoValidationValidator).Assembly);
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider));
using (var db = container.Resolve<IDbConnectionFactory>().OpenDbConnection())
{
db.DropAndCreateTable<Rockstar>(); //Create table if not exists
db.Insert(Rockstar.SeedData); //Populate with seed data
}
SetConfig(new HostConfig {
AdminAuthSecret = "secret",
DebugMode = true,
});
}
示例6: Configure
public override void Configure(Container container)
{
SetConfig(new EndpointHostConfig {ServiceStackHandlerFactoryPath = "api"});
//Set JSON web services to return idiomatic JSON camelCase properties
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
ServiceStack.Text.JsConfig.DateHandler = JsonDateHandler.ISO8601;
Plugins.Add(new CorsFeature()); //Registers global CORS Headers
RequestFilters.Add((httpReq, httpRes, requestDto) =>
{
//Handles Request and closes Responses after emitting global HTTP Headers
if (httpReq.HttpMethod == "OPTIONS")
httpRes.EndServiceStackRequest();
});
//Enable the validation feature
Plugins.Add(new ValidationFeature());
//This method scans the assembly for validators
container.RegisterValidators(typeof(AppHost).Assembly);
container.Register<ICacheClient>(new MemoryCacheClient());
// register RavenDB dependencies
ConfigureRavenDb(container);
// register authentication framework
ConfigureAuthentication(container);
}
示例7: Configure
public override void Configure(Container container)
{
JsConfig.EmitCamelCaseNames = true;
Plugins.Add(new RazorFormat());
//Comment out 2 lines below to change to use local FileSystem instead of S3
var s3Client = new AmazonS3Client(AwsConfig.AwsAccessKey, AwsConfig.AwsSecretKey, RegionEndpoint.USEast1);
VirtualFiles = new S3VirtualPathProvider(s3Client, AwsConfig.S3BucketName, this);
container.Register<IPocoDynamo>(c => new PocoDynamo(AwsConfig.CreateAmazonDynamoDb()));
var db = container.Resolve<IPocoDynamo>();
db.RegisterTable<Todos.Todo>();
db.RegisterTable<EmailContacts.Email>();
db.RegisterTable<EmailContacts.Contact>();
db.InitSchema();
//AWS Auth
container.Register<ICacheClient>(new DynamoDbCacheClient(db, initSchema:true));
container.Register<IAuthRepository>(new DynamoDbAuthRepository(db, initSchema:true));
Plugins.Add(CreateAuthFeature());
//EmailContacts
ConfigureSqsMqServer(container);
ConfigureEmailer(container);
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(EmailContacts.CreateContact).Assembly);
}
示例8: Configure
public override void Configure (Container container)
{
container.Register<ICacheClient> (new MemoryCacheClient ());
var appSettings = new AppSettings ();
Plugins.Add (new AuthFeature (() => new WrenchAuthUserSession (),
new[] { new GoogleOpenIdOAuthProvider (appSettings) }));
Plugins.Add (new ValidationFeature ());
container.RegisterValidators (typeof (WrenchAppHost).Assembly);
Routes.AddFromAssembly (typeof (WrenchAppHost).Assembly);
}
示例9: Register
public static void Register(Container container)
{
// add service validation
container.RegisterValidators(ReuseScope.Container, typeof(ServiceStackServiceSolutionValidationAseembly).Assembly);
container.RegisterAutoWiredAs<WidgetManager, IWidgetManager>();
container.RegisterAutoWiredAs<InMemoryWidgetRepository, IWidgetRepository>();
RegisterExternalAssemblies(container);
}
示例10: Configure
public override void Configure(Container container)
{
SetConfig(CreateEndpointHostConfig());
JsConfig.EmitCamelCaseNames = true;
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(AppHost).Assembly);
container.RegisterAutoWired<BicyleRepository>();
}
示例11: Configure
public override void Configure(Container container)
{
container.Register<ICacheClient>(new MemoryCacheClient());
ConfigureData(container);
ConfigureAuth(container);
ConfigureCors(container);
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(Global).Assembly);
}
示例12: RegisterDependencies
private static void RegisterDependencies(Container container)
{
//Register all your dependencies
container.Register<ICacheClient>(new MemoryCacheClient());
container.Register<IAuth>(new PasswordAuth());
container.Register<IRepository>(AzureStorage.CreateSingleton(
RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString")
));
container.RegisterAutoWired<XpmsAuthProvider>().ReusedWithin(ReuseScope.Hierarchy);
container.RegisterProcesses<AbstractProcess>();
container.RegisterValidators(typeof(SignupRequestValidator).Assembly);
container.RegisterDataRecords<IRepoData>(typeof(AzureStorage).Assembly);
}
示例13: Configure
public override void Configure (Container container)
{
LogManager.LogFactory = new NLogFactory ();
this.RequestFilters.Add ((req, resp, requestDto) => {
ILog log = LogManager.GetLogger (GetType ());
log.Info (string.Format (
"REQ {0}: {1} {2} {3} {4} {5}\n",
DateTimeOffset.Now.Ticks, req.HttpMethod,
req.OperationName, req.RemoteIp, req.RawUrl, req.UserAgent));
});
this.RequestFilters.Add ((req, resp, requestDto) => {
ILog log = LogManager.GetLogger (GetType ());
log.Info (string.Format (
"RES {0}: {1} {2}\n",
DateTimeOffset.Now.Ticks, resp.StatusCode, resp.ContentType));
});
JsConfig.DateHandler = JsonDateHandler.ISO8601;
Plugins.Add (new AuthFeature (() => new AuthUserSession (),
new IAuthProvider[] { new BasicAuthProvider () })
);
Plugins.Add (new RegistrationFeature ());
Plugins.Add (new RequestLogsFeature ());
container.RegisterAutoWiredAs<Scheduler, IScheduler> ();
container.Register<ICacheClient> (new MemoryCacheClient ());
container.Register<IDbConnectionFactory> (new OrmLiteConnectionFactory
(@"Data Source=db.sqlite;Version=3;", SqliteOrmLiteDialectProvider.Instance));
//Use OrmLite DB Connection to persist the UserAuth and AuthProvider info
container.Register<IUserAuthRepository> (c => new OrmLiteAuthRepository (c.Resolve<IDbConnectionFactory> ()));
Plugins.Add (new ValidationFeature ());
container.RegisterValidators (typeof(AppHost).Assembly);
var config = new EndpointHostConfig ();
if (m_debugEnabled) {
config.DebugMode = true; //Show StackTraces in service responses during development
config.WriteErrorsToResponse = true;
config.ReturnsInnerException = true;
}
container.AutoWire (this);
SetConfig (config);
CreateMissingTables (container);
}
示例14: Configure
public override void Configure(Container container)
{
//ASP.NET MVC integration
ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
SetConfig(CreateEndpointHostConfig());
JsConfig.EmitCamelCaseNames = true;
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(AppHost).Assembly);
container.RegisterAutoWired<BicyleRepository>();
}
示例15: ConfigureAppHost
public void ConfigureAppHost(Container container, bool useTestDatabase = false)
{
JsConfig.EmitCamelCaseNames = true;
JsConfig.DateHandler = JsonDateHandler.ISO8601;
_appHost.Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof (AppHost).Assembly);
container.Register<ICacheClient>(new MemoryCacheClient());
_appHost.Plugins.Add(new AuthFeature(
() => new AuthUserSession(),
new IAuthProvider[]
{
new CredentialsAuthProvider()
}));
if (useTestDatabase)
{
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(
":memory:",
false,
SqliteDialect.Provider));
}
else
{
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(
ConfigurationManager.ConnectionStrings["SqlLiteConnection"].ConnectionString.MapHostAbsolutePath(),
SqliteDialect.Provider));
}
container.RegisterAutoWiredAs<BicyleRepository, IBicyleRepository>().ReusedWithin(ReuseScope.Request);
container.Register<IUserAuthRepository>(c =>
new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>()));
var userAuthRepository = (OrmLiteAuthRepository) container.Resolve<IUserAuthRepository>();
userAuthRepository.CreateMissingTables();
if (userAuthRepository.GetUserAuthByUserName("[email protected]") == null)
{
userAuthRepository.CreateUserAuth(
new UserAuth {Email = "[email protected]", DisplayName = "Admin User"}, "admin");
}
InitializeDatabase(container);
}