Beispiel #1
0
            public override void Configure(Container container)
            {
                JsConfig.EmitCamelCaseNames = true;

                this.RequestFilters.Add((req, res, dto) => {
                    var requestFilter = dto as RequestFilter;
                    if (requestFilter != null)
                    {
                        res.StatusCode = requestFilter.StatusCode;
                        if (!requestFilter.HeaderName.IsNullOrEmpty())
                        {
                            res.AddHeader(requestFilter.HeaderName, requestFilter.HeaderValue);
                        }
                        res.Close();
                    }

                    var secureRequests = dto as IRequiresSession;
                    if (secureRequests != null)
                    {
                        res.ReturnAuthRequired();
                    }
                });

                this.Container.Register <IDbConnectionFactory>(c =>
                                                               new OrmLiteConnectionFactory(
                                                                   "~/App_Data/db.sqlite".MapHostAbsolutePath(),
                                                                   SqliteOrmLiteDialectProvider.Instance)
                {
                    ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
                });

                this.Container.Register <ICacheClient>(new MemoryCacheClient());
                //this.Container.Register<ICacheClient>(new BasicRedisClientManager());

                ConfigureAuth(container);

                //this.Container.Register<ISessionFactory>(
                //    c => new SessionFactory(c.Resolve<ICacheClient>()));

                var dbFactory = this.Container.Resolve <IDbConnectionFactory>();

                dbFactory.Exec(dbCmd => dbCmd.CreateTable <Movie>(true));
                ModelConfig <Movie> .Id(x => x.Title);

                Routes
                .Add <Movies>("/custom-movies", "GET")
                .Add <Movies>("/custom-movies/genres/{Genre}")
                .Add <Movie>("/custom-movies", "POST,PUT")
                .Add <Movie>("/custom-movies/{Id}")
                .Add <MqHostStats>("/mqstats");

                var resetMovies = this.Container.Resolve <ResetMoviesService>();

                resetMovies.Post(null);

                ValidationFeature.Init(this);
                container.RegisterValidators(typeof(CustomersValidator).Assembly);

                SessionFeature.Init(this);

                //var onlyEnableFeatures = Feature.All.Remove(Feature.Jsv | Feature.Soap);
                SetConfig(new EndpointHostConfig {
                    //EnableFeatures = onlyEnableFeatures,
                    DebugMode = true,                     //Show StackTraces for easier debugging
                });

                var redisManager = new BasicRedisClientManager();
                var mqHost       = new RedisMqHost(redisManager, 2, null);

                mqHost.RegisterHandler <Reverse>(this.Container.Resolve <ReverseService>().Execute);
                mqHost.Start();

                this.Container.Register((IMessageService)mqHost);
            }
 public override void Configure(Container container)
 {
     ValidationFeature.Init(this);
     container.Register <IAddressValidator>(new AddressValidator());
     container.RegisterValidators(typeof(CustomersValidator).Assembly);
 }
 public override void Configure(Container container)
 {
     ValidationFeature.Init(this);
     container.RegisterValidators(typeof(UserValidator).Assembly);
 }