示例#1
0
        public override void Configure(Funq.Container container)
        {
            container.Register<IDbConnectionFactory>(
                    c =>
                        new OrmLiteConnectionFactory("~/App_Data/db.sqlite".MapHostAbsolutePath(),
                            SqliteDialect.Provider)
                        {
                            ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
                        });

            container.RegisterAutoWired<JournalService>();
            container.RegisterAutoWired<SessionService>();

            using (var db = container.Resolve<IDbConnectionFactory>().Open())
            {
                db.DropAndCreateTable<Journal>();
                db.DropAndCreateTable<Session>();
                db.DropAndCreateTable<Task>();
                db.DropAndCreateTable<JournalNote>();
                db.DropAndCreateTable<SessionNote>();

                //Seed Lists
                db.InsertAll(SeedData.JournalSeed);
                db.InsertAll(SeedData.JournalNoteSeed);
                db.InsertAll(SeedData.SessionSeed);
                db.InsertAll(SeedData.TaskSeed);
                db.InsertAll(SeedData.SessionNoteSeed);
            }
        }
        public override void Configure(Funq.Container container)
        {
            container.RegisterAutoWired<PlayersRepository>();

            Plugins.Add(new ValidationFeature());

            container.RegisterValidators(typeof(AppHost).Assembly);
        }
示例#3
0
        private void RegisterDependencies(Funq.Container container)
        {
            var ormLiteConnectionFactory =
                new OrmLiteConnectionFactory(System.IO.Path.GetFullPath("~/../../../App_Data/data.db"), SqliteDialect.Provider);

            container.Register<IDbConnectionFactory>(ormLiteConnectionFactory);
            container.RegisterAutoWired<CommandRepository>();
        }
            public override void Configure(Funq.Container container)
            {
                //var dbConnectionFactory = new OrmLiteConnectionFactory
                //        (WebConfigurationManager.ConnectionStrings["snomed"].ToString(),
                //        SqlServerOrmLiteDialectProvider.Instance);
                //container.Register<IDbConnectionFactory>(dbConnectionFactory);
                //using (var db = dbConnectionFactory.Open())
                //{
                //    db.CreateTable<Concept>();
                //}

                container.RegisterAutoWired<DataRepository>();
            }
示例#5
0
 public override void Configure(Funq.Container container)
 {
     Plugins.Add(new CorsFeature());
     //GlobalRequestFilters.Add((httpReq, httpRes, requestDto) =>
     //{
     //    if (httpReq.HttpMethod == "OPTIONS")
     //    {
     //        httpRes.EndRequest();
     //    }
     //});
     var dbConnectionFactory = new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/wordData.txt"), SqliteDialect.Provider);
     container.Register<IDbConnectionFactory>(dbConnectionFactory);
     container.RegisterAutoWired<DataRepository>();
 }
        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            JsConfig.EmitCamelCaseNames = true;

            //Register Typed Config some services might need to access
            var appConfig = new AppConfig(new AppSettings());

            //appconfig will contain properties from web.config
            container.Register(appConfig);

            //inform api that this will be using BasicAuth to authenticate/authorize users
            Plugins.Add(new AuthFeature(
                () => new AuthUserSession(),
                new IAuthProvider[] { new BasicAuthProvider(), }));

            //add registration functionality (user will need admin role to access this)
            Plugins.Add(new RegistrationFeature());

            //add validation using fluent validation package
            Plugins.Add(new ValidationFeature());

            //register service to validate
            container.RegisterValidators(typeof(AwardService).Assembly);

            if (appConfig.UseRedis){
                //setup cache client to user redis
                container.Register<IRedisClientsManager>(c => new PooledRedisClientManager(appConfig.RedisReadWriteHosts.ToArray()));
                container.Register<ICacheClient>(c => c.Resolve<IRedisClientsManager>().GetCacheClient());

                //setup redis for authentication repository
                container.Register<IUserAuthRepository>(c => new RedisAuthRepository(c.Resolve<IRedisClientsManager>()));
            }
            else
            {
                //setup cache client to be InMemory
                container.Register<ICacheClient>(c => new MemoryCacheClient());

                //setup authentication repository to be InMemory
                container.Register<IUserAuthRepository>(c => new InMemoryAuthRepository());
            }
            

            //seed possible users
            SeedUsers(container.Resolve<IUserAuthRepository>());

            //register any repository classes here
            container.RegisterAutoWired<AwardRepository>();
        }
 public override void Configure(Funq.Container container)
 {
     Plugins.Add(new CorsFeature());
     RequestFilters.Add((httpReq, httpRes, requestDto) =>
     {
         //Handles Request and closes Responses after emitting global HTTP Headers
         if (httpReq.HttpMethod == "OPTIONS")
             httpRes.EndRequest();
     });
     var dbConnectionFactory =
         new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/bookData.txt"),
             SqliteDialect.Provider);
     container.Register<IDbConnectionFactory>(dbConnectionFactory);
     container.RegisterAutoWired<DataRepository>();
 }
示例#8
0
            public override void Configure(Funq.Container container)
            {
                Plugins.Add(new CorsFeature());
                PreRequestFilters.Add((httpReq, httpRes) =>
                {
                    if (httpReq.Verb == "OPTIONS")
                        httpRes.EndRequest();
                });

                var dbConnectionFactory =
                    new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/bookdata.txt"),
                        SqliteDialect.Provider);

                container.Register<IDbConnectionFactory>(dbConnectionFactory);
                container.RegisterAutoWired<DataRepository>();
            }
示例#9
0
            public override void Configure(Funq.Container container)
            {
                container.RegisterAutoWired<DataRepository>();

                Plugins.Add(new CorsFeature(
                    allowOriginWhitelist: new[] { "http://localhost:36085", "http://localhost", "http://hwl59427d", "http://edwaitingtimes-test", "http://edwaitingtimes" },
                    allowedHeaders: "Content-Type",
                    allowCredentials: true
                    ));

                // Globally enable CORS for all OPTION requests
                this.PreRequestFilters.Add((httpReq, httpRes) =>
                {
                    //Handles Request and closes Responses after emitting global HTTP Headers
                    if (httpReq.Verb == "OPTIONS")
                        httpRes.EndRequest();
                });

                //Set JSON web services to return idiomatic JSON camelCase properties
                ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
            }
            public override void Configure(Funq.Container container)
            {
                //to inject third-party IoC (for example for NInject use SrviceStack.ContainerAdapter.NInject)
                //IKernel kernel=new StandartKernel();
                //kernel.Bind<TrackedDataRepository>().ToSelf();
                //container.Adapter=new NinjectContainerAdapter(kernel);  -> provide a adapter layer for NInject to use in Funq

                Plugins.Add(new AuthFeature(() => new AuthUserSession(),
                            new IAuthProvider[] { new BasicAuthProvider() ,
                                new TwitterAuthProvider(new AppSettings())}));

                Plugins.Add(new RegistrationFeature());

                //register validators
                Plugins.Add(new ValidationFeature());
                container.RegisterValidators(typeof(Common.Entry).Assembly, typeof(EntryService).Assembly);

                //request logs
                Plugins.Add(new RequestLogsFeature()); // added ability to view request via http:/..../requestlogs

                //cache registration
                container.Register<ICacheClient>(new MemoryCacheClient());
                container.Register<IRedisClientsManager>(new PooledRedisClientManager("localhost:6379"));
                //container.Register<ICacheClient>(r => (ICacheClient)r.Resolve<IRedisClientsManager>().GetCacheClient());

                var userRepository = new InMemoryAuthRepository();
                container.Register<IUserAuthRepository>(userRepository);

                string hash;
                string salt;
                new SaltedHash().GetHashAndSaltString("password1", out hash, out salt);

                userRepository.CreateUserAuth(new UserAuth()
                {
                    Id = 1,
                    DisplayName = "Joe user",
                    Email = "*****@*****.**",
                    UserName = "******",
                    LastName = "jname",
                    PasswordHash = hash,
                    Salt = salt,
                    Roles = new List<string> { RoleNames.Admin }//,
                    //Permissions = new List<string> { "GetStatus", "AddStatus" }
                }, "password1");

                //automatically inject in all public properties
                container.RegisterAutoWired<TrackedDataRepository>().ReusedWithin(Funq.ReuseScope.Default);
                container.RegisterAutoWired<TrackedDataRepository2>().ReusedWithin(Funq.ReuseScope.Default);

                var dbConFactory = new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/data.txt"), SqliteDialect.Provider)
                {
                    ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
                };
                container.Register<IDbConnectionFactory>(dbConFactory);

                SetConfig(new EndpointHostConfig { DebugMode = true });

                var mqService = new RedisMqServer(container.Resolve<IRedisClientsManager>());
                mqService.RegisterHandler<Entry>(ServiceController.ExecuteMessage);
                mqService.Start();

                //install Razor
                Plugins.Add(new RazorFormat());
            }