Example #1
0
        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            var connectionString = ConfigurationManager.ConnectionStrings["conString"].ToString();
            Register<IDbConnectionFactory>(new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider));

            var appSettings = new AppSettings();
            Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[]
                {
                    new CredentialsAuthProvider(),
                    new FacebookAuthProvider(appSettings),
                    new GoogleOpenIdOAuthProvider(appSettings),
                }));

            Plugins.Add(new RegistrationFeature());

            var userRep = new OrmLiteAuthRepository(container.Resolve<IDbConnectionFactory>());
            container.Register<IUserAuthRepository>(userRep);
            var redisCon = ConfigurationManager.AppSettings["redisUrl"].ToString();
            container.Register<IRedisClientsManager>(new PooledRedisClientManager(20, 60, redisCon));
            container.Register<ICacheClient>(c => (ICacheClient)c.Resolve<IRedisClientsManager>().GetCacheClient());

            userRep.CreateMissingTables();
            //Set MVC to use the same Funq IOC as ServiceStack
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
        public override void Configure(Funq.Container container)
        {
            PathProvider.BinaryPath = "~".MapAbsolutePath();

            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

			RequestBinders.Add(typeof(CommitAttempt), request => new CommitAttempt()
			{
				UserAgent = request.Headers["User-Agent"],
				RawBody = request.GetRawBody()
			});
			

            Routes
                .Add<CommitAttempt>("/commit")
                .Add<CommitMessages>("/commits")
                .Add<MessageErrors>("/errors")

            //    //.Add<CommitMessage>("/commitMessage")
              ;

            var redisFactory = new PooledRedisClientManager("localhost:6379");
            container.Register<IRedisClientsManager>(redisFactory);
            //var mqHost = new RedisMqHost(redisFactory);
            var mqHost = new RedisMqServer(redisFactory);

            container.Register<IMessageService>(mqHost);
            container.Register(mqHost.MessageFactory);

            mqHost.RegisterHandler<CommitAttempt>(ServiceController.ExecuteMessage);
            //mqHost.RegisterHandler<CommitMessage>(ServiceController.ExecuteMessage);

            mqHost.Start();
        }
        public void Install(Container container)
        {
            var userRepo = new InMemoryAuthRepository();

            container.Register<IUserAuthRepository>(userRepo);

            //HACK: Add default users
            var users = new[]
                {
                    new User("Admin", "AdminPassword"),
                    new User("cyberzed", "cyberzed")
                };

            foreach (var user in users)
            {
                string hash;
                string salt;

                new SaltedHash().GetHashAndSaltString(user.Password, out hash, out salt);

                userRepo.CreateUserAuth(
                    new UserAuth
                        {
                            DisplayName = user.Username,
                            UserName = user.Username,
                            PasswordHash = hash,
                            Salt = salt
                        },
                    user.Password);
            }
        }
Example #4
0
        public override void Configure(Funq.Container container)
        {
            var appConfig = (TsonServiceConfig)this.Container.Resolve<ITsonServiceConfig>();

            JsConfig.EmitCamelCaseNames = true;

            SetConfig(
                new HostConfig
            {
                EnableFeatures = Feature.All & ~Feature.Soap,
                DefaultContentType = "application/json",
                AppendUtf8CharsetOnContentTypes = new HashSet<string>
                {
                    "application/json", "application/xml"
                },
                #if DEBUG
                DebugMode = true,
                #else
                DebugMode = false,
                #endif
            });

            log.Info(appConfig.ToString());

            Plugins.Add(new ToolBelt.ServiceStack.CorsFeature(
                allowOrigins: appConfig.CorsAllowedOrigins,
                allowHeaders: ToolBelt.ServiceStack.CorsFeature.DefaultHeaders + ",Accept",
                exposeHeaders: true,
                allowCredentials: false
            ));
        }
Example #5
0
        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            //Configure User Defined REST Paths
            Routes
                .Add<Sms>("/sms")
                .Add<Schedule>("/schedule")
                .Add<Coordinator>("/coordinator");

            //Change the default ServiceStack configuration
            //SetConfig(new EndpointHostConfig {
            //    DebugMode = true, //Show StackTraces in responses in development
            //});

            //Enable Authentication
            //ConfigureAuth(container);

            //Register all your dependencies
            //container.Register(new TodoRepository());

            //Register In-Memory Cache provider.
            //For Distributed Cache Providers Use: PooledRedisClientManager, BasicRedisClientManager or see: https://github.com/ServiceStack/ServiceStack/wiki/Caching
            container.Register<ICacheClient>(new MemoryCacheClient());
            container.Register<ISessionFactory>(c =>
                new SessionFactory(c.Resolve<ICacheClient>()));

            container.RegisterAutoWiredAs<RavenDocStore, IRavenDocStore>();
            container.RegisterAutoWiredAs<DateTimeUtcFromOlsenMapping, IDateTimeUtcFromOlsenMapping>();
            container.RegisterAutoWiredAs<CoordinatorModelToMessageMapping, ICoordinatorModelToMessageMapping>();
            container.RegisterAutoWiredAs<CoordinatorApiModelToMessageMapping, ICoordinatorApiModelToMessageMapping>();
            container.RegisterAutoWiredAs<CurrentUser, ICurrentUser>();

            var busConfig = NServiceBus.Configure.With()
                .DefineEndpointName("SmsWeb")
                .DefaultBuilder()
                    .DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith("Commands"))
                    .DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith("Events"))
                    .DefiningMessagesAs(t => t.Namespace == "SmsMessages")
                    .Log4Net()
                .XmlSerializer()
                .MsmqTransport()
                    .IsTransactional(true)
                    .PurgeOnStartup(false)
                .UnicastBus()
                    .LoadMessageHandlers();
            NServiceBus.Configure.Instance.Configurer.ConfigureComponent<RavenDocStore>(DependencyLifecycle.SingleInstance);
            NServiceBus.Configure.Instance.Configurer.ConfigureComponent<SmsScheduleStatusHandler>(DependencyLifecycle.InstancePerCall);
                    //.LoadMessageHandlers<SmsScheduleStatusHandler>();

            busConfig.Configurer.ConfigureComponent<DateTimeUtcFromOlsenMapping>(DependencyLifecycle.SingleInstance);

            var bus = busConfig.CreateBus().Start();//() => NServiceBus.Configure.Instance.ForInstallationOn<NServiceBus.Installation.Environments.Windows>().Install());

            //container.Register(new SmsScheduleStatusHandler(new RavenDocStore()));
            container.Register(bus);
            //Set MVC to use the same Funq IOC as ServiceStack
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
            /// <summary>
            /// AppHostHttpListenerBase method.
            /// </summary>
            /// <param name="container">SS's funq container</param>
            public override void Configure(Funq.Container container) {
                EndpointHostConfig.Instance.GlobalResponseHeaders.Clear();

			//Signal advanced web browsers what HTTP Methods you accept
			//base.SetConfig(new EndpointHostConfig());
			Routes.Add<PlainText>("/test/plaintext", "GET");
            }
Example #7
0
            public override void Configure(Funq.Container container)
            {
                //register any dependencies your services use, e.g:
                //container.Register<ICacheClient>(new MemoryCacheClient());

                Plugins.Add (new SwaggerFeature ());

                Routes.Add<LocationRequest> ("/Location/Update/", "POST");

                SetConfig (new EndpointHostConfig {
                    DebugMode = true
                });

                this.PreRequestFilters.Add ((req, resp) => {

                });

                this.RequestFilters.Add ((IHttpRequest httpReq, IHttpResponse httpResp, object requestDto) => {
                    var appSettings = new AppSettings ();

                    if (httpReq.Headers ["Authorization-API"] == null) {
                        throw HttpError.Unauthorized ("No Authorization Header provided");
                    }

                    string storedAPIKey = appSettings.Get ("GeoAPIKey", "");
                    string passedAPIKey = httpReq.Headers ["Authorization-API"];

                    if (String.IsNullOrEmpty (storedAPIKey)) {
                        throw HttpError.Unauthorized ("API Key not configured");
                    } else if (storedAPIKey != passedAPIKey) {
                        throw HttpError.Unauthorized ("API Key passed from the client was not found");
                    }

                });
            }
Example #8
0
        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            //Configure User Defined REST Paths
            Routes
                .Add<Hello>("/hello")
                .Add<Hello>("/hello/{Name*}")
                .Add<Todo>("/todos")
                .Add<Todo>("/todos/{Id}");

            //Change the default ServiceStack configuration
            //SetConfig(new EndpointHostConfig {
            //    DebugMode = true, //Show StackTraces in responses in development
            //});

            //Enable Authentication
            //ConfigureAuth(container);

            //Register all your dependencies
            container.Register(new TodoRepository());

            //Register In-Memory Cache provider.
            //For Distributed Cache Providers Use: PooledRedisClientManager, BasicRedisClientManager or see: https://github.com/ServiceStack/ServiceStack/wiki/Caching
            container.Register<ICacheClient>(new MemoryCacheClient());
            container.Register<ISessionFactory>(c =>
                new SessionFactory(c.Resolve<ICacheClient>()));

            //container.Register<IRedisClientsManager>(c => new PooledRedisClientManager("ec2-54-247-0-119.eu-west-1.compute.amazonaws.com:6379"));
            //container.Register<ICacheClient>(c => (ICacheClient)c.Resolve<IRedisClientsManager>().GetCacheClient());

            //Set MVC to use the same Funq IOC as ServiceStack
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
            var dataFilePath = AppDomain.CurrentDomain.GetData("DataDirectory").ToString() + "\\data.db";
            container.Register<IDbConnectionFactory>(new OrmLiteConnectionFactory(dataFilePath, SqliteOrmLiteDialectProvider.Instance));
            new DataSeeder().Seed(); //Comment out to stop resetting the data

            //Configure User Defined REST Paths
            Routes
              .Add<Hello>("/hello")
              .Add<Hello>("/hello/{Name*}");

            //Uncomment to change the default ServiceStack configuration
            //SetConfig(new EndpointHostConfig {
            //    EnableFeatures = Feature.All.Remove(Feature.Metadata)
            //});

            //Enable Authentication
            //ConfigureAuth(container);

            //Register all your dependencies
            container.Register(new TodoRepository());

            //Set MVC to use the same Funq IOC as ServiceStack
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
Example #10
0
        public override void Configure(Funq.Container container)
        {
            const Feature disableFeatures = Feature.Jsv | Feature.Soap;

            SetConfig(new EndpointHostConfig
            {
                EnableFeatures = Feature.All.Remove(disableFeatures),
                DebugMode = true,
                GlobalResponseHeaders =
                {
                    { "Access-Control-Allow-Origin", "*" },
                    { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
                }
            });

            container.Register<IResourceManager>(new ConfigurationResourceManager());
            container.Register<IValidator<Todo>>(new TodoValidator());

            container.Register(c => new Config(c.Resolve<IResourceManager>()));
            var appConfig = container.Resolve<Config>();

            container.Register<IDbConnectionFactory>(c =>
                new OrmLiteConnectionFactory(appConfig.ConnectionString, SqlServerOrmLiteDialectProvider.Instance));

            ConfigureDatabase.Init(container.Resolve<IDbConnectionFactory>());

            Routes
                .Add<Todos>("/todos")
                .Add<Todos>("/todos/{Id}");

            log.InfoFormat("AppHost Configured: " + DateTime.Now);
        }
Example #11
0
        public override void Configure(Funq.Container container)
        {
            // To hook in windsor as default container
            var windsorContainer = new WindsorContainer();
            Container.Adapter = new WindsorContainerAdapter(windsorContainer);

            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            //Configure User Defined REST Paths
            Routes
                .Add<HelloRequest>("/hello")
                .Add<HelloRequest>("/hello/{Name*}");

            //Uncomment to change the default ServiceStack configuration
            SetConfig(new EndpointHostConfig {
                DebugMode = true //Show StackTraces when developing
                //EnableFeatures = Feature.Json | Feature.Metadata
            });

            //Register all your dependencies
            //Using an in-memory cache
            windsorContainer.Register(Component.For<ICacheClient>().ImplementedBy<MemoryCacheClient>());

            this.RequestFilters.Add((request, response, requestDto) =>
                {
                    var x = 1;
                });

            this.ResponseFilters.Add((request, response, responseDto) =>
                {
                    var x = 1;
                });
        }
Example #12
0
        public override void Configure(Funq.Container container)
        {
            SetConfig(new EndpointHostConfig { ServiceStackHandlerFactoryPath = "api"});

            container.Register<IRedisClientsManager>(c => new PooledRedisClientManager());
            container.Register<IRepository>(c => new Repository(c.Resolve<IRedisClientsManager>()));
        }
Example #13
0
        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
            // ServiceStack.Text.JsConfig.EmitLowercaseUnderscoreNames = true;

            //Configure User Defined REST Paths
            //Routes
            //  .Add<Hello>("/hello")
            //  .Add<Hello>("/hello/{Name*}");

            //Uncomment to change the default ServiceStack configuration
            //SetConfig(new EndpointHostConfig {
            //});

            //Enable Authentication
            //ConfigureAuth(container);

            //Register all your dependencies
            //container.Register(new TodoRepository());

            container.Register<IRedisClientsManager>(new BasicRedisClientManager("localhost:6379"));

            //Set MVC to use the same Funq IOC as ServiceStack
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
Example #14
0
        public override void Configure(Funq.Container container)
        {
            container.Register(this.buildManager);

            //this.Routes.Add<IEnumerable<TinyBuildStatus>>("/status")
            //           .Add<TinyBuildStatus>("/status/{Id}");
        }
Example #15
0
 public override void Configure(Funq.Container container)
 {
     container.RegisterAutoWiredAs<Login, ILogin>();
     container.RegisterAutoWiredAs<LabsNews, ILabsNews>();
     container.RegisterAutoWiredAs<NewsletterDal, INewsletterDal>();
     container.RegisterAutoWiredAs<NewsStorage, INewsStorage>();
 }
Example #16
0
        public override void Configure(Funq.Container container)
        {
            Plugins.Add(new CorsFeature());
            Plugins.Add(new SwaggerFeature());

            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            //Configure User Defined REST Paths
            Routes
              .Add<Hello>("/hello")
              .Add<Hello>("/hello/{Name*}");

            //Uncomment to change the default ServiceStack configuration
            //SetConfig(new HostConfig
            //{
            //});

            //Enable Authentication
            //ConfigureAuth(container);

            //Register all your dependencies
            container.Register(new TodoRepository());

            //Set MVC to use the same Funq IOC as ServiceStack
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
Example #17
0
            public override void Configure(Funq.Container container)
            {
                Plugins.Add (new RequestLogsFeature ());
                    this.Config.DefaultContentType = "Json";
                    //container.RegisterAutoWired<InMemoryFileSystem>();

                    InMemoryFileSystem fileSystem = new InMemoryFileSystem ();
                    container.Register<InMemoryFileSystem> (fileSystem);

                    Console.WriteLine ("Application_Start ---->. Begin");

                    //Start the ISIS System
                    IsisSystem.Start ();

                    Console.WriteLine ("ISIS Started :)");

                    FileServerComm.fileServerGroupName = "FileServer";
                    FileServerComm fileSrvComm = FileServerComm.getInstance ();

                    fileSrvComm.getFileHandler ().filesystem = fileSystem;

                    System.IO.StreamReader file = new System.IO.StreamReader ("bootstrap.txt");
                    string line = file.ReadLine ();
                    Console.WriteLine (line);

                    bool isBootStrap = false;
                    if (line.Equals ("1")) {
                        isBootStrap = true;
                    }

                    fileSrvComm.ApplicationStartup(isBootStrap,FileServerComm.fileServerGroupName);

                    Console.WriteLine("Application_Start. End");
            }
Example #18
0
        /* Uncomment to enable ServiceStack Authentication and CustomUserSession */
        private void ConfigureAuth(Funq.Container container)
        {
            var appSettings = new AppSettings();

            //Default route: /auth/{provider}
            Plugins.Add(new AuthFeature(() => new CustomUserSession(),
                new IAuthProvider[] {
                    new CredentialsAuthProvider(appSettings),
                    new FacebookAuthProvider(appSettings),
                    new TwitterAuthProvider(appSettings),
                    new BasicAuthProvider(appSettings),
                }));

            //Default route: /register
            Plugins.Add(new RegistrationFeature());

            //Requires ConnectionString configured in Web.Config
            var connectionString = ConfigurationManager.ConnectionStrings["AppDb"].ConnectionString;
            container.Register<IDbConnectionFactory>(c =>
                new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider));

            container.Register<IUserAuthRepository>(c =>
                new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>()));

            container.Resolve<IUserAuthRepository>().InitSchema();
        }
 public override void Configure(Funq.Container container)
 {
     Routes.Add<Hello>("/hello").Add<Hello>("/hello/{Name}");
     Routes.Add<Files>("/fileupload/{Name}").Add<Files>("/fileupload");
     Routes.Add<CookieInfo>("/cookie").Add<CookieInfo>("/cookie/{Name}");
     Routes.Add<Redirect>("/redirector").Add<Redirect>("/redirector/redirected");
 }
Example #20
0
            public override void Configure(Funq.Container container)
            {
                //Set JSON web services to return idiomatic JSON camelCase properties
                ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
                var appSettings = new AppSettings();
                //Registers authorization service and endpoints /auth and /auth{provider}

                Plugins.Add(new AuthFeature(() => new AuthUserSession(),
                    new IAuthProvider[] {
                    new CredentialsAuthProvider(),              //HTML Form post of UserName/Password credentials
                    new TwitterAuthProvider(appSettings),       //Sign-in with Twitter
                    //new FacebookAuthProvider(appSettings),      //Sign-in with Facebook
                    new GoogleOpenIdOAuthProvider(appSettings), //Sign-in with Google OpenId
                }) {HtmlRedirect = "/Camper/SignIn"});

                //Provide service for new users to register so they can login with supplied credentials.
                Plugins.Add(new RegistrationFeature());

                NHibernateConfigurator.Initialize<CamperMapping>();
                //Store User Data into the referenced SqlServer database
                container.Register<IUserAuthRepository>(c =>
                    new NHibernateUserAuthRepository()); //Can Use OrmLite DB Connection to persist the UserAuth and AuthProvider info

                //override the default registration validation with your own custom implementation
                container.RegisterAs<MyRegistrationValidator, IValidator<Registration>>();

                var redisCon = ConfigurationManager.AppSettings["redisUrl"].ToString();
                container.Register<IRedisClientsManager>(new PooledRedisClientManager(20, 60, redisCon));
                container.Register<ICacheClient>(c => (ICacheClient)c.Resolve<IRedisClientsManager>().GetCacheClient());

                ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
            }
Example #21
0
 public override void Configure(Funq.Container container)
 {
     //register user-defined REST-ful urls
     Routes
       .Add<HelloRequest>("/hello")
       .Add<HelloRequest>("/hello/{Name}");
 }
Example #22
0
 public override void Configure(Funq.Container container)
 {
     //register any dependencies your services use, e.g:
     //container.Register<ICacheClient>(new MemoryCacheClient());
     TriePopulator populator = TriePopulator.FromFile("wordlist.txt");
     container.Register<Trie>(populator.Trie);
 }
        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            ApiRegistration.Register(Routes);

            //Change the default ServiceStack configuration
            SetConfig(new EndpointHostConfig
            {
                DebugMode = true, //Show StackTraces in responses in development

                //enable CORS
                GlobalResponseHeaders = {	{ "Access-Control-Allow-Origin", "*" },
                                            { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
                                            { "Access-Control-Allow-Headers", "Content-Type" },
                                        }

            });

            Plugins.Add(new ValidationFeature());

            container.RegisterValidators(typeof(ApplicationRequestValidator).Assembly);

            Plugins.Add(new RequestLogsFeature());

            //Register In-Memory Cache provider.
            //For Distributed Cache Providers Use: PooledRedisClientManager, BasicRedisClientManager or see: https://github.com/ServiceStack/ServiceStack/wiki/Caching
            container.Register<ICacheClient>(new MemoryCacheClient());

            //Set MVC to use the same Funq IOC as ServiceStack
            ServiceRegistration.RegisterAllContainers(container);
        }
Example #24
0
 public static void ResolveDependencies(Funq.Container container)
 {
     //Register a external dependency-free
     container.Register<ICacheClient>(new MemoryCacheClient());
     //Configure an alt. distributed peristed cache that survives AppDomain restarts. e.g Redis
     //container.Register<IRedisClientsManager>(c => new PooledRedisClientManager("localhost:6379"));
 }
Example #25
0
        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            //Configure User Defined REST Paths
            Routes
                .Add<Order>("/order")
                .Add<Order>("/order/{AuthCode}/{OrderNo}/{Status*}");

            //Change the default ServiceStack configuration
            //SetConfig(new EndpointHostConfig {
            //    DebugMode = true, //Show StackTraces in responses in development
            //});

            //Enable Authentication
            //ConfigureAuth(container);

            //Register all your dependencies
            //container.Register(new TodoRepository());

            //Register In-Memory Cache provider.
            //For Distributed Cache Providers Use: PooledRedisClientManager, BasicRedisClientManager or see: https://github.com/ServiceStack/ServiceStack/wiki/Caching
            container.Register<ICacheClient>(new MemoryCacheClient());
            container.Register<ISessionFactory>(c =>
                new SessionFactory(c.Resolve<ICacheClient>()));

            //Set MVC to use the same Funq IOC as ServiceStack
            //ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
Example #26
0
        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            //Configure User Defined REST Paths
            Routes.Add<Hello>("/hello")
                  .Add<Hello>("/hello/{Name*}");

            //Uncomment to change the default ServiceStack configuration
            //SetConfig(new EndpointHostConfig {
            //});

            //Enable Authentication
            //ConfigureAuth(container);

            //IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory(":memory:", false, SqliteOrmLiteDialectProvider.Instance);
            IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory(GetFileConnectionString(),
                                                                          false, SqliteOrmLiteDialectProvider.Instance);
            this.CreateSqliteInMemoryTables(dbFactory);

            //string connectionString = ConfigurationManager.ConnectionStrings["ServiceStackTest"].ConnectionString;
            //IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory(connectionString, false, SqlServerOrmLiteDialectProvider.Instance);

            container.Register<IDbConnectionFactory>(dbFactory);

            //Register all your dependencies
            container.Register(c => new TodoRepository(c.Resolve<IDbConnectionFactory>()));
        }
Example #27
0
        public override void Configure(Funq.Container container)
        {
            container.Adapter = new StructureMapContainerAdapter();

            SetConfig(new EndpointHostConfig() { ServiceStackHandlerFactoryPath = "api" });
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            //Configure User Defined REST Paths
            Routes
                .Add<GetUserItemsRequest>("/user/items/", "GET")
                .Add<GetUserItemsRequest>("/userownerships/", "GET")
                .Add<AddUserItemRequest>("/user/items/", "POST")
                .Add<AddOrganisationItemRequest>("/org/{OwnerId}/items/add/")
                .Add<ConnectRequest>("/connection/add/{FromUserId}/{ToUserId}/")
                .Add<BorrowItemRequest>("/borrow/{OwnershipId}/{RequestorId}/")
                .Add<ItemRequest>("/items/{itemid}/", "GET")
                .Add<ItemRequest>("/items/", "GET")
                .Add<NewItemRequest>("/items/", "POST")
                .Add<RemoveItemRequest>("/user/items/{OwnershipId}/", "DELETE")
                ;

            //Enable Authentication
            ConfigureAuth(container);
            Plugins.Add(new SessionFeature());
        }
        public override void Configure(Funq.Container container)
        {
            //Resource manager
            container.Register<IResourceManager>(new ConfigurationResourceManager());
            var appSettings = container.Resolve<IResourceManager>();

            Plugins.Add(new SessionFeature());

            string redis = appSettings.GetString("redis_connection_string");
            container.Register<IRedisClientsManager>(c => new BasicRedisClientManager(redis));

            // Register storage for user sessions 
            container.Register<ICacheClient>(c => c.Resolve<IRedisClientsManager>().GetCacheClient()).ReusedWithin(Funq.ReuseScope.None);
            container.Register<ISessionFactory>(c => new SessionFactory(c.Resolve<ICacheClient>()));

            // Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            // Validation
            Plugins.Add(new ValidationFeature());
            container.RegisterValidators(typeof(Namespace_ApiProject).Assembly);

            Plugins.Add(new AuthFeature(() => new CustomUserSession(),
                                        new IAuthProvider[]
                                        {
                                            new FbOAuth2Provider(appSettings),
                                            new VkOAuth2Provider(appSettings),
                                        }));
            
            //container.Register<ICacheClient>(new MemoryCacheClient());
            Plugins.Add(new ServiceStack.Api.Swagger.SwaggerFeature());

            container.Adapter = new StructureMapContainerAdapter();
        }
Example #29
0
        public override void Configure(Funq.Container container)
        {
            //http://stackoverflow.com/questions/13206038/servicestack-razor-default-page/13206221

            var razor3 = new RazorFormat();

            this.Plugins.Add(razor3);
            this.Plugins.Add(new RequestLogsFeature()
                {
                    EnableErrorTracking = true,
                    EnableResponseTracking = true,
                    EnableSessionTracking = true,
                    EnableRequestBodyTracking = true,
                    RequiredRoles = new string[0]
                });

            this.PreRequestFilters.Add(SimplePreRequestFilter);

            this.RequestFilters.Add(SimpleRequestFilter);

            //this.SetConfig( new EndpointHostConfig()
            //    {
            //        DebugMode = false,

            //    } );


            this.Routes.Add<HelloRequest>("/hello");
            this.Routes.Add<HelloRequest>("/hello/{Name}");
            this.Routes.Add<FooRequest>("/Foo/{WhatToSay}");
            this.Routes.Add<DefaultViewFooRequest>("/DefaultViewFoo/{WhatToSay}");
        }
        public override void Configure(Funq.Container container)
        {
            Routes
                .Add<SimulateList>("/simulation")
                .Add<Simulate>("/simulation/{ModelName}/{VariableNames*}");

        }