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


C# Container.RegisterValidators方法代码示例

本文整理汇总了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
        }
开发者ID:xiangxli,项目名称:EmailContacts,代码行数:31,代码来源:Global.asax.cs

示例2: Configure

        public override void Configure(Container container)
        {
            Plugins.Add(new ValidationFeature());
            container.RegisterValidators(typeof(AppHost).Assembly);

            container.RegisterAutoWired<BicyleRepository>();
        }
开发者ID:garora,项目名称:AngularJSForDotNet,代码行数:7,代码来源:AppHost.cs

示例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);
        }
开发者ID:garora,项目名称:AngularJSForDotNet,代码行数:25,代码来源:AppHost.cs

示例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
        }
开发者ID:Gozhack,项目名称:EmailContacts,代码行数:29,代码来源:Global.asax.cs

示例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,
            });
        }
开发者ID:jin29neci,项目名称:ServiceStack,代码行数:28,代码来源:AppHost.cs

示例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);
        }
开发者ID:Gimly,项目名称:License.Manager,代码行数:31,代码来源:AppHost.cs

示例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);
        }
开发者ID:ServiceStackApps,项目名称:AwsApps,代码行数:27,代码来源:AppHost.cs

示例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);
			}
开发者ID:vargaz,项目名称:monkeywrench,代码行数:10,代码来源:Global.asax.cs

示例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);
        }
开发者ID:wasecajesus,项目名称:ServiceStackServiceSolution,代码行数:10,代码来源:ContainerManager.cs

示例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>();
        }
开发者ID:garora,项目名称:AngularJSForDotNet,代码行数:11,代码来源:AppHost.cs

示例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);
            }
开发者ID:TheFailBoat,项目名称:IssueTracker,代码行数:11,代码来源:Global.asax.cs

示例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);
 }
开发者ID:sufong2001,项目名称:XpmsAzure,代码行数:13,代码来源:AppHost.cs

示例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);
		}
开发者ID:frachstudia,项目名称:studies,代码行数:50,代码来源:AppHost.cs

示例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>();
        }
开发者ID:garora,项目名称:AngularJSForDotNet,代码行数:14,代码来源:AppHost.cs

示例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);
        }
开发者ID:garora,项目名称:AngularJSForDotNet,代码行数:48,代码来源:AppHostConfiguration.cs


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