public override void Configure(Container container) { //Permit modern browsers (e.g. Firefox) to allow sending of any REST HTTP Method base.SetConfig(new HostConfig { DebugMode = true, }); Plugins.Add(new CorsFeature()); container.Register<IAppSettings>(new AppSettings()); container.Register(c => new ExampleConfig(c.Resolve<IAppSettings>())); var appConfig = container.Resolve<ExampleConfig>(); container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory( appConfig.ConnectionString.MapHostAbsolutePath(), SqliteOrmLiteDialectProvider.Instance)); ConfigureDatabase.Init(container.Resolve<IDbConnectionFactory>()); //If you give Redis a try, you won't be disappointed. This however requires Redis to be installed. //container.Register<ICacheClient>(c => new BasicRedisClientManager()); log.InfoFormat("AppHost Configured: {0}", DateTime.Now); }
public override void Configure(Container container) { //Signal advanced web browsers what HTTP Methods you accept base.SetConfig(new EndpointHostConfig { GlobalResponseHeaders = { { "Access-Control-Allow-Origin", "*" }, { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" }, }, WsdlServiceNamespace = "http://www.servicestack.net/types", WsdlServiceTypesNamespace = "http://www.servicestack.net/types", }); container.Register<IResourceManager>(new ConfigurationResourceManager()); var appSettings = container.Resolve<IResourceManager>(); container.Register(c => new ExampleConfig(c.Resolve<IResourceManager>())); var appConfig = container.Resolve<ExampleConfig>(); container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory( appConfig.ConnectionString.MapAbsolutePath(), SqliteOrmLiteDialectProvider.Instance)); if (appSettings.Get("PerformTestsOnInit", false)) { log.Debug("Performing database tests..."); DatabaseTest(container.Resolve<IDbConnectionFactory>()); } }
public override void Configure(Container container) { // register list to track time _times = new List<long>(); container.Register(x => _times); log4net.Config.XmlConfigurator.Configure(); var connectionString = "Server=localhost;Port=5432;Database=test;Username=test;Password=password;Timeout=1000;SslMode=disable"; if (_ssl) { connectionString = "Server=localhost;Port=5432;Database=test;Username=test;Password=password;Timeout=1000;SslMode=require;Ssl=true"; } //NHibernate factory _factory = CreateSessionFactory(connectionString); container.Register(x => _factory); //Npgsql connection NpgsqlEventLog.EchoMessages = true; NpgsqlEventLog.Level = LogLevel.Normal; _conn = new NpgsqlConnection(connectionString); _conn.Open(); container.Register(x => _conn); //ORMLite container.Register<IDbConnectionFactory>(new OrmLiteConnectionFactory(connectionString, PostgreSqlDialect.Provider)); }
public override void FinishedLaunching(NSObject notification) { try { LSSharedFileList.InsertLoginItem(NSBundle.MainBundle.BundlePath); } catch { } var container = new Container(); Tepeyac.Funq.Registry.Register(container); container.Register<IFiber>("GuiFiber", c => { var executor = c.Resolve<IExecutor>() ?? new Executor(); var fiber = new CocoaFiber(executor); fiber.Start(); return fiber; }); container.Register<ILauncher>(c => new Tepeyac.UI.Cocoa.Launcher()); container.Register<IBurritoDayView>(c => new StatusItemBurritoDayView(c)); container.Resolve<IBurritoDayView>(); }
public FunqRegistry Register(Container container) { container.Register<ICacheClient>(new MemoryCacheClient()); container.Register<IDbConnection>(c => new ProfiledDbConnection( new SqlCeConnection(ConfigurationManager.ConnectionStrings["Iso3166_1"].ConnectionString), Profiler.Current)) .ReusedWithin(ReuseScope.None); container.RegisterAutoWiredAs<CountryRepository, ICountryRepository>() .ReusedWithin(ReuseScope.None); container.RegisterAutoWiredAs<LanguageRepository, ILanguageRepository>() .ReusedWithin(ReuseScope.None); var logFactory = new ElmahVerboserLoggerFactory(new ElmahLogFactory(new NullLogFactory())); // allows ServiceStack to log its own error (for instance 404) LogManager.LogFactory = logFactory; // allow services to declare the ILogFactory dependency instead of depending on the global LogManager container.Register<ILogFactory>(logFactory); container.RegisterAutoWiredAs<TranslationRepository, ITranslationRepository>() .ReusedWithin(ReuseScope.None); return this; }
public override void Configure(Container container) { //Signal advanced web browsers what HTTP Methods you accept base.SetConfig(new HostConfig { DebugMode = true, }); container.Register<IAppSettings>(new AppSettings()); var appSettings = container.Resolve<IAppSettings>(); container.Register(c => new ExampleConfig(c.Resolve<IAppSettings>())); var appConfig = container.Resolve<ExampleConfig>(); container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory( appConfig.ConnectionString.MapAbsolutePath(), SqliteOrmLiteDialectProvider.Instance)); if (appSettings.Get("PerformTestsOnInit", false)) { log.Debug("Performing database tests..."); DatabaseTest(container.Resolve<IDbConnectionFactory>()); } }
public override void Configure(Container container) { LogManager.LogFactory = new ConsoleLogFactory(); JsConfig.EmitCamelCaseNames = true; JsConfig.IncludeNullValues = true; JsConfig.ExcludeTypeInfo = true; SetConfig(new EndpointHostConfig { GlobalResponseHeaders = { { "Cache-Control", "no-cache" } }, DefaultContentType = ContentType.Json, MapExceptionToStatusCode = { { typeof(VariableResourceNotFoundException), 404 }, // not found { typeof(MissingCommandParameterException), 400 }, // bad request } }); container.Register<ILog>(x => LogManager.LogFactory.GetLogger("win-driver")); container.Register<IElementRepository>(new ElementRepository()); container.Register<ISessionRepository>(new SessionRepository()); container.Register<IAutomationService>(new UIAutomationService(container.Resolve<IElementRepository>())); }
/// <summary> /// Application specific configuration /// This method should initialize any IoC resources utilized by your web service classes. /// </summary> /// <param name="container"></param> public override void Configure(Container container) { Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new CustomAuthentication(), })); container.Register<ICacheClient>(new MemoryCacheClient()); var userRepository = new InMemoryAuthRepository(); container.Register<IUserAuthRepository>(userRepository); }
public override void Configure(Container container) { //Permit modern browsers (e.g. Firefox) to allow sending of any REST HTTP Method base.SetConfig(new EndpointHostConfig { GlobalResponseHeaders = { { "Access-Control-Allow-Origin", "*" }, { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" }, }, }); container.Register<IResourceManager>(new ConfigurationResourceManager()); container.Register(c => new ExampleConfig(c.Resolve<IResourceManager>())); var appConfig = container.Resolve<ExampleConfig>(); container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory( appConfig.ConnectionString.MapHostAbsolutePath(), SqliteOrmLiteDialectProvider.Instance)); ConfigureDatabase.Init(container.Resolve<IDbConnectionFactory>()); //The MemoryCacheClient is a great way to get started with caching; nothing external to setup. container.Register<ICacheClient>(c => new MemoryCacheClient()); //If you give Redis a try, you won't be disappointed. This however requires Redis to be installed. //container.Register<ICacheClient>(c => new BasicRedisClientManager()); log.InfoFormat("AppHost Configured: {0}", DateTime.Now); }
public override void Configure(Container container) { JsConfig.EmitCamelCaseNames = true; Plugins.Add(new SwaggerFeature()); var manager = new InsteonManager(insteonSource); container.Register(manager); var settingsProvider = new SettingsProvider(new RoamingAppDataStorage("Insteon")); var mySettings = settingsProvider.GetSettings<SmartThingsSettings>(); container.Register(mySettings); manager.Network.Devices.DeviceStatusChanged += (sender, data) => { logger.DebugFormat("{0}:{1}", data.Device.Address, data.DeviceStatus); var settings = container.Resolve<SmartThingsSettings>(); var cb = new SmartThingsCallbacks(settings); cb.PushDeviceStatusUpdate(data.Device, data.DeviceStatus); }; GlobalResponseFilters.Add((req, res, dto) => { res.AddHeader("X-Insteon", ServiceName); }); manager.Connect(); }
public override void Configure(Container container) { Plugins.Add(new AuthFeature(() => new CustomUserSession(), new AuthProvider[] { new CredentialsAuthProvider(), //HTML Form post of UserName/Password credentials new BasicAuthProvider(), //Sign-in with Basic Auth })); container.Register<ICacheClient>(new MemoryCacheClient()); var userRep = new InMemoryAuthRepository(); container.Register<IUserAuthRepository>(userRep); string hash; string salt; new SaltedHash().GetHashAndSaltString("test1", out hash, out salt); userRep.CreateUserAuth(new UserAuth { Id = 1, DisplayName = "DisplayName", Email = "*****@*****.**", UserName = "******", FirstName = "FirstName", LastName = "LastName", PasswordHash = hash, Salt = salt, }, "test1"); }
/// <summary> /// Configure the container with the necessary routes for your ServiceStack application. /// </summary> /// <param name="container">The built-in IoC used with ServiceStack.</param> public override void Configure(Container container) { //Permit modern browsers (e.g. Firefox) to allow sending of any REST HTTP Method SetConfig(new EndpointHostConfig { GlobalResponseHeaders = { { "Access-Control-Allow-Origin", "*" }, { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" }, }, }); Plugins.Add(new CorsFeature(allowedHeaders: "Content-Type, Authorization, Session-Id")); ServiceStack.Text.JsConfig.EmitCamelCaseNames = true; var config = new SiteConfig(new ConfigurationResourceManager()); container.Register(config); var logger = new LogHelper(ConfigService.AppName); container.Register(logger); var dbConnectionFactory = new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["MainServer"].ConnectionString, SqlServerDialect.Provider); container.Register<IDbConnectionFactory>(dbConnectionFactory); }
public override void Configure(Container container) { JsConfig.EmitCamelCaseNames = true; var appSettings = new TextFileSettings("~/appSettings.txt".MapHostAbsolutePath(), ":"); container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory( appSettings.Get("database"), SqlServerDialect.Provider)); container.Register(x => new Log4NetFactory(true)); LogManager.LogFactory = container.Resolve<Log4NetFactory>(); container.Register<ILog>(x => LogManager.GetLogger(GetType())); AwsAccessKey = appSettings.Get("awsAccessKey"); AwsSecretKey = appSettings.Get("awsSecretKey"); Plugins.Add(new CorsFeature()); using (var db = container.Resolve<IDbConnectionFactory>().Open()) { db.CreateTableIfNotExists<LinkUrls>(); db.CreateTableIfNotExists<LinkImages>(); } Routes.Add<FindLinkUrl>("/urls/{Id}", "GET") .Add<FindLinkUrl>("/urls", "GET") .Add<AddLinkUrl>("/urls", "POST") .Add<StartGetImages>("/start", "GET"); }
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); }
public override void Configure(Container container) { Plugins.Add(new RegistrationFeature()); Plugins.Add ( new AuthFeature ( () => new AuthUserSession(), new IAuthProvider[] { new BasicAuthProvider(), new CustomCredentialsAuthProvider() } ) {HtmlRedirect = "/common/login" } ); Plugins.Add(new RazorFormat()); SetConfig(new EndpointHostConfig { DefaultContentType = ContentType.Json, CustomHttpHandlers = { { HttpStatusCode.NotFound, new RazorHandler("/notfound") } } }); container.Register<IRedisClientsManager>(new PooledRedisClientManager("localhost:6379")); UserRepository = new RedisAuthRepository(container.Resolve<IRedisClientsManager>()); container.Register<IUserAuthRepository>(UserRepository); }
/// <summary> /// Application specific configuration /// This method should initialize any IoC resources utilized by your web service classes. /// </summary> /// <param name="container"></param> public override void Configure(Container container) { StorageConfig.StorageConnexionString = ConfigurationManager.AppSettings["storage"]; //Config examples //this.Plugins.Add(new PostmanFeature()); //this.Plugins.Add(new CorsFeature()); Plugins.Add(new AuthFeature(() => new AuthUserEntrySession(), new IAuthProvider[] { //new BasicAuthProvider(), //Sign-in with HTTP Basic Auth new CredentialsAuthProvider(), //HTML Form post of UserName/Password credentials })); Plugins.Add(new AzureRegistrationFeature() { AtRestPath = "/api/register" }); container.Register<ICacheClient>(new MemoryCacheClient()); container.Register<IUserAuthRepository>(new AzureAuthProvider()); AuthenticateService.CurrentSessionFactory = () => new AuthUserEntrySession(); this.Plugins.Add(new RazorFormat()); // Hack pour que le F5 fonctionne avec angular-route this.CustomErrorHttpHandlers[HttpStatusCode.NotFound] = new RazorHandler("/"); //this.CustomErrorHttpHandlers[HttpStatusCode.Unauthorized] = new RazorHandler("/login"); JsConfig.DateHandler = DateHandler.ISO8601; }
private void RegisterDependencies(Container iocContainer) { var store = new EmbeddableDocumentStore { DataDirectory = "Data" }.Initialize(); iocContainer.Register(store); iocContainer.Register(c => c.Resolve<IDocumentStore>().OpenSession()).ReusedWithin(ReuseScope.Request); }
public override void Configure(Container container) { Plugins.Add(new RazorFormat()); container.Register(new DataSource()); container.Register<IDbConnectionFactory>( new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider) { ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current) }); using (var db = container.Resolve<IDbConnectionFactory>().Open()) { db.CreateTableIfNotExists<Rockstar>(); db.Insert(Rockstar.SeedData); } JsConfig.EmitCamelCaseNames = true; //Register Typed Config some services might need to access var appSettings = new AppSettings(); //Register a external dependency-free container.Register<ICacheClient>(new MemoryCacheClient()); //Configure an alt. distributed persistent cache that survives AppDomain restarts. e.g Redis //container.Register<IRedisClientsManager>(c => new PooledRedisClientManager("localhost:6379")); //Enable Authentication an Registration ConfigureAuth(container); //Create your own custom User table using (var db = container.Resolve<IDbConnectionFactory>().Open()) db.DropAndCreateTable<UserTable>(); }
public override void Configure(Container container) { //Permit modern browsers (e.g. Firefox) to allow sending of any REST HTTP Method base.SetConfig(new EndpointHostConfig { GlobalResponseHeaders = { { "Access-Control-Allow-Origin", "*" }, { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" }, }, }); container.Register<IResourceManager>(new ConfigurationResourceManager()); container.Register(c => new ExampleConfig(c.Resolve<IResourceManager>())); var appConfig = container.Resolve<ExampleConfig>(); container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory( appConfig.ConnectionString.MapHostAbsolutePath(), SqliteOrmLiteDialectProvider.Instance)); ConfigureDatabase.Init(container.Resolve<IDbConnectionFactory>()); //register different cache implementations depending on availability const bool hasRedis = false; if (hasRedis) container.Register<ICacheClient>(c => new BasicRedisClientManager()); else container.Register<ICacheClient>(c => new MemoryCacheClient()); log.InfoFormat("AppHost Configured: " + DateTime.Now); }
/// <summary> /// Application specific configuration /// This method should initialize any IoC resources utilized by your web service classes. /// </summary> /// <param name="container"></param> public override void Configure(Container container) { SetConfig(new HostConfig { DebugMode = true }); //Config examples Plugins.Add(new PostmanFeature()); Plugins.Add(new CorsFeature()); Plugins.Add(new AuthFeature(() => new CustomUserSession(), new IAuthProvider[] { new BasicAuthProvider(AppSettings), new CredentialsAuthProvider(AppSettings), }) { IncludeRegistrationService = true, HtmlRedirect = "/", }); container.Register<IRedisClientsManager>(c => new PooledRedisClientManager("localhost:6379")); container.Register(c => c.Resolve<IRedisClientsManager>().GetCacheClient()); container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory( AppSettings.GetString("AppDb"), PostgreSqlDialect.Provider)); container.Register<IAuthRepository>(c => new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>()) { UseDistinctRoleTables = AppSettings.Get("UseDistinctRoleTables", true), }); var authRepo = (OrmLiteAuthRepository)container.Resolve<IAuthRepository>(); MyServices.ResetUsers(authRepo); }
public override void Configure(Container container) { container.Register<IResourceManager>(new ConfigurationResourceManager()); container.Register(c => new RemoteInfoConfig(c.Resolve<IResourceManager>())); log.InfoFormat("AppHost Configured: " + DateTime.Now); }
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 = "*****@*****.**", DisplayName= "Admin User"}, "admin"); container.Register<IUserAuthRepository>(userAuthRepository); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var container = new Container(); Tepeyac.Funq.Registry.Register(container); container.Register<IFiber>("GuiFiber", c => c.Resolve<IFiber>()); /* container.Register<IFiber>("GuiFiber", c => { var executor = c.Resolve<IExecutor>() ?? new Executor(); var invoke = new SynchronizeInvoke(new WindowsFormsSynchronizationContext()); var fiber = new FormFiber(invoke, executor); fiber.Start(); return fiber; }); */ container.Register<IBurritoDayView>(c => new BurritoDayView(c)); container.Resolve<IBurritoDayView>(); Application.Run(); }
public static void Init(Container container, string connectionString) { var dbConnectionFactory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider); container.Register<IDbConnectionFactory>(dbConnectionFactory); container.Register<ICacheClient>(new MemoryCacheClient()); //user auth testing var userRepo = new InMemoryAuthRepository(); string hash; string salt; new SaltedHash().GetHashAndSaltString("ssapi", out hash, out salt); userRepo.CreateUserAuth(new UserAuth { Id = 1, DisplayName = "Api User", Email = "*****@*****.**", UserName = "******", FirstName = "Api", LastName = "User", PasswordHash = hash, Salt = salt }, "ssapi"); container.Register<IUserAuthRepository>(userRepo); }
public override void Configure(Container container) { //Permit modern browsers (e.g. Firefox) to allow sending of any REST HTTP Method base.SetConfig(new EndpointHostConfig { GlobalResponseHeaders = { { "Access-Control-Allow-Origin", "*" }, { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, PATCH" }, }, DefaultContentType = ContentType.Json }); var config = new AppConfig(new ConfigurationResourceManager()); container.Register(config); OrmLiteConfig.DialectProvider= FirebirdOrmLiteDialectProvider.Instance; IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory( ConfigUtils.GetConnectionString("ApplicationDb")); container.Register<Factory>( new Factory(){ DbFactory=dbFactory } ); ConfigureAuth(container); log.InfoFormat("AppHost Configured: " + DateTime.Now); }
/// <inheritdoc /> public void Configure(Container container) { Log.Info(" - Registering dependency in CustomFunqlet"); container.Register<IDependency>(new Dependency()); container.Register<IBehavior<IComplexExtension>>(ctx => new DependencyUsingBehavior(ctx.Resolve<IDependency>())); }
public override void Configure(Container container) { string sc = ConfigurationManager.AppSettings.Get("DbConnection"); string rchost= ConfigurationManager.AppSettings.Get("SessionRedisHost"); rchost= (string.IsNullOrEmpty(rchost))? "localhost:6379": rchost; string rcpassword= ConfigurationManager.AppSettings.Get("SessionRedisPassword"); string rcdbs= ConfigurationManager.AppSettings.Get("SessionRedisDb"); int rcdb; if(! int.TryParse(rcdbs, out rcdb) ) rcdb= 10; string sstout = ConfigurationManager.AppSettings.Get("SessionTimeout"); int sessionTimeout; if(! int.TryParse(sstout, out sessionTimeout) ) sessionTimeout= 60*8; var cacheClient= new BasicRedisClientManager( new string[]{rchost}, new string[]{rchost}, rcdb); cacheClient.GetClient().Password= rcpassword; container.Register<IAuthProvider>( new BdAuthProvider() { DbFactory=new ConnectionFactory(sc, FirebirdDialectProvider.Instance), AuthUserSession= new UserSession() { CacheClient= cacheClient, TimeOut=sessionTimeout, } }); string phost= ConfigurationManager.AppSettings.Get("CacheHost"); phost = (string.IsNullOrEmpty(phost))?"localhost:6379":phost; string pdbs= ConfigurationManager.AppSettings.Get("CacheDb"); int pdb ; if(! int.TryParse(pdbs, out pdb) ) pdb= 9; string ppassword= ConfigurationManager.AppSettings.Get("CachePassword"); var p = new PooledRedisClientManager(new string[]{phost}, new string[]{phost}, pdb); p.GetClient().Password= ppassword; container.Register<ICacheClient>( p); container.Register<IDbConnectionFactory>( new ConnectionFactory(sc, FirebirdDialectProvider.Instance) ); //Permit modern browsers (e.g. Firefox) to allow sending of any REST HTTP Method base.SetConfig(new EndpointHostConfig { GlobalResponseHeaders = { { "Access-Control-Allow-Origin", "*" }, { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" }, { "Access-Control-Allow-Headers","X-Requested-With"} }, }); log.InfoFormat("AppHost Configured: " + DateTime.Now); }
public Funq() { container = new Container(); container.Register(c => new Game()).ReusedWithin(ReuseScope.Container); container.Register(c => new Player(c.Resolve<Game>(), c.Resolve<Gun>())).ReusedWithin(ReuseScope.None); container.Register(c => new Gun(c.Resolve<Game>(), c.LazyResolve<Bullet>())).ReusedWithin(ReuseScope.None); container.Register(c => new Bullet(c.Resolve<Game>())).ReusedWithin(ReuseScope.None); }
private Container BuildContainer() { var container = new Container(); container.Register(c => _webServer ?? new IisExpressWebServer(_webApplication)); container.Register(c => _webDriver.Invoke()); container.Register(c => _camera); return container; }
public override void Configure(Container container) { container.Register(c => new AppConfig(new AppSettings())); var config = container.Resolve<AppConfig>(); container.Register<IRedisClientsManager>(c => new BasicRedisClientManager(config.RedisHostAddress)); }
//Configure ServiceStack Authentication and CustomUserSession private void ConfigureAuth(Funq.Container container) { Routes .Add <Register>("/register"); var appSettings = new AppSettings(); Plugins.Add(new AuthFeature(() => new CustomUserSession(), new IAuthProvider[] { new CredentialsAuthProvider(appSettings), new FacebookAuthProvider(appSettings), new TwitterAuthProvider(appSettings), new GoogleOpenIdOAuthProvider(appSettings), new OpenIdOAuthProvider(appSettings), new DigestAuthProvider(appSettings), new BasicAuthProvider(appSettings), })); Plugins.Add(new RegistrationFeature()); container.Register <IAuthRepository>(c => new OrmLiteAuthRepository(c.Resolve <IDbConnectionFactory>())); var authRepo = (OrmLiteAuthRepository)container.Resolve <IAuthRepository>(); if (new AppSettings().Get("RecreateTables", true)) { authRepo.DropAndReCreateTables(); } else { authRepo.InitSchema(); } }
public override void Configure(Funq.Container container) { ServiceStack.Text.JsConfig.EmitCamelCaseNames = true; Plugins.Add(new RazorFormat()); var ormLiteConnectionFactory = new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["studentDbConn"].ConnectionString, ServiceStack.OrmLite.SqlServer.SqlServerOrmLiteDialectProvider.Instance); container.Register <IDbConnectionFactory>(ormLiteConnectionFactory); container.Register(c => new StudentDbRepository()).ReusedWithin(ReuseScope.Request); container.RegisterAutoWired <StudentDbRepository>(); DbInitializer.InitializeDb(ormLiteConnectionFactory); }
//Configure ServiceStack Authentication and CustomUserSession private void ConfigureAuth(Funq.Container container) { Routes .Add <Auth>("/auth") .Add <Auth>("/auth/{provider}") .Add <Registration>("/register"); var appSettings = new AppSettings(); AuthFeature.Init(this, () => new CustomUserSession(), new IAuthProvider[] { new CredentialsAuthProvider(appSettings), new FacebookAuthProvider(appSettings), new TwitterAuthProvider(appSettings), new BasicAuthProvider(appSettings), }); RegistrationFeature.Init(this); container.Register <IUserAuthRepository>(c => new OrmLiteAuthRepository(c.Resolve <IDbConnectionFactory>())); var authRepo = (OrmLiteAuthRepository)container.Resolve <IUserAuthRepository>(); if (new AppSettings().Get("Recr eateTables", true)) { authRepo.DropAndReCreateTables(); } else { authRepo.CreateMissingTables(); } }
public override void Configure(Funq.Container container) { ServiceStack.Text.JsConfig.EmitCamelCaseNames = true; Routes. Add <Contact>("/contacts"). Add <Contact>("/contacts/{id}"); container.Register <IRedisClientsManager>(new BasicRedisClientManager()); }
public override void Configure(Funq.Container container) { var dbConnectionFactory = new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/data.txt"), SqliteDialect.Provider); container.Register <IDbConnectionFactory>(dbConnectionFactory); container.RegisterAutoWired <TrackedRepository>(); }
public override void Configure(Funq.Container container) { SetConfig(new HostConfig { DebugMode = true }); container.Register <IDbConnectionFactory>(c => new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider)); }
public override void Configure(Funq.Container container) { //Set JSON web services to return idiomatic JSON camelCase properties ServiceStack.Text.JsConfig.EmitCamelCaseNames = true; JsConfig.DateHandler = JsonDateHandler.ISO8601; //Configure User Defined REST Paths Routes .Add <Hello>("/hello") .Add <Hello>("/hello/{Name*}") .Add <Hello>("/todos") .Add <Hello>("/todos/{Id}") .Add <Project>("/projects") .Add <Project>("/projects/{Id}") .Add <Note>("/notes") .Add <Note>("/notes/{Id}") .Add <Note>("/projects/{ProjectId}/notes") .Add <Note>("/projects/{ProjectId}/notes/{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<NoteService>(c => new NoteService(c.Resolve<IDocumentSession>())); //Set MVC to use the same Funq IOC as ServiceStack ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container)); }
/// <summary> /// Application specific configuration /// This method should initialize any IoC resources utilized by your web service classes. /// </summary> /// <param name="container"></param> public override void Configure(Container container) { JsConfig.EmitCamelCaseNames = true; Plugins.Add(new RazorFormat()); Plugins.Add(new ServerEventsFeature()); MimeTypes.ExtensionMimeTypes["jsv"] = "text/jsv"; SetConfig(new HostConfig { DebugMode = AppSettings.Get("DebugMode", false), DefaultContentType = MimeTypes.Json, AllowFileExtensions = { "jsx" }, }); CustomErrorHttpHandlers.Remove(HttpStatusCode.Forbidden); //Register all Authentication methods you want to enable for this web app. Plugins.Add(new AuthFeature( () => new AuthUserSession(), new IAuthProvider[] { new TwitterAuthProvider(AppSettings) //Sign-in with Twitter })); container.RegisterAutoWiredAs <MemoryChatHistory, IChatHistory>(); var redisHost = AppSettings.GetString("RedisHost"); if (redisHost != null) { container.Register <IRedisClientsManager>(new RedisManagerPool(redisHost)); container.Register <IServerEvents>(c => new RedisServerEvents(c.Resolve <IRedisClientsManager>())); container.Resolve <IServerEvents>().Start(); } }
public override void Configure(Funq.Container container) { Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new ConcordAPI.ServiceInterface.ConcordyaBasicAuthProvider() //Sign-in with Basic Auth })); Plugins.Add(new RegistrationFeature()); //Plugins.Add(new AutoQueryFeature { MaxLimit = 100 }); container.Register <ICacheClient>(new MemoryCacheClient()); container.Register <IDbConnectionFactory>(c => new OrmLiteConnectionFactory( new AppSettings().Get( "ConcordAPI.Properties.Settings.LocalSQLConnectionString", db_conn_string), SqlServerDialect.Provider)); //container.Resolve var userRepository = new OrmLiteAuthRepository <UserAccount, UserAccountDetail>(container.Resolve <IDbConnectionFactory>()); container.Register <IUserAuthRepository>(userRepository); InitialDbTables(container, userRepository); }
// Configure your AppHost with the necessary configuration and dependencies your App needs public override void Configure(Funq.Container container) { //Register Redis Client Manager singleton in ServiceStack's built-in Func IOC container.Register(s => new RepositoryFactories()); container.Register <IRepositoryProvider>(c => new RepositoryProvider(c.TryResolve <RepositoryFactories>())).ReusedWithin(ReuseScope.None); container.Register <IOpfcUow>(c => new OpfcUow(c.TryResolve <IRepositoryProvider>())).ReusedWithin(ReuseScope.None); container.Register(s => new ServiceFactories(s.Resolve <IOpfcUow>())).ReusedWithin(ReuseScope.None); container.Register <IServiceProvider>(c => new ServiceProvider(c.TryResolve <ServiceFactories>())).ReusedWithin(ReuseScope.None); container.Register <IServiceUow>(c => new ServiceUow(c.TryResolve <IServiceProvider>())).ReusedWithin(ReuseScope.None); container.Register <ITask>(t => new CompositeTask(new AutoMapperConfigTask())); container.Resolve <ITask>().Execute(); }
public override void Configure(Funq.Container container) { container.Register <IAuthProvider>((c) => new AuthProvider()); Routes .Add <GetDataRequest>("/GetData"); this.RequestFilters.Add((req, res, dto) => { //if (!req.IsSecureConnection) //{ // res.StatusCode = 401; // res.Close(); //} if (req.Headers["Authorization"] != null) { const string key = "Bearer "; string accessToken = null; var header = req.Headers["Authorization"]; if (header.StartsWith(key)) { accessToken = header.Substring(key.Length); } if (string.IsNullOrWhiteSpace(accessToken)) { res.StatusCode = 401; res.Close(); } //Lookup var provider = container.Resolve <IAuthProvider>(); if (!provider.UserIsValid(accessToken)) { res.StatusCode = 401; res.Close(); } } }); }
private void ConfigureAuth(Funq.Container container) { LogManager.LogFactory = new ConsoleLogFactory(); container.Register <IUserAuthRepository>(c => new UserAuthRepository(c.Resolve <IDbConnectionFactory>())); //Register all Authentication methods you want to enable for this web app. this.Plugins.Add(new AuthFeature( () => new Session(), //Use your own typed Custom UserSession type 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 BasicAuthProvider() //Sign-in with Basic Auth })); //Provide service for new users to register so they can login with supplied credentials. //Plugins.Add(new RegistrationFeature()); //override the default registration validation with your own custom implementation //container.RegisterAs<CustomRegistrationValidator, IValidator<Registration>>(); }
public void Register <T>(T instance) { container.Register(instance); }
public static void MyClassInitialize(TestContext testContext) { //Arrange //Set up Funq IOS for Dependency injection TestContainer.Register <IEventRepository>(new EventRepository_Mock()); }
/// <summary> /// Configure the given container with the /// registrations provided by the funqlet. /// </summary> /// <param name="container">Container to register.</param> public override void Configure(Funq.Container container) { ServiceStack.OrmLite.OrmLiteConfig.CommandTimeout = 60; WebEas.Log.WebEasNLogLogger.Application = "PFE"; base.Configure(container); // new EnumSerializerConfigurator().WithAssemblies(new List<Assembly> { typeof(HierarchyNode).Assembly }).WithNullableEnumSerializers().Configure(); this.SetConfig(new HostConfig { WsdlServiceNamespace = "http://schemas.dcom.sk/private/Egov/pfe/1.0", SoapServiceName = "EsamPfe", #if DEBUG || DEVELOP || INT || ITP DebugMode = true, EnableFeatures = Feature.All.Remove(this.disableFeaturesDebug), #else DebugMode = false, EnableFeatures = Feature.All.Remove(this.disableFeatures), #endif DefaultContentType = MimeTypes.Json, AllowJsonpRequests = true, #if DEVELOPCRM WebHostUrl = "https://esam-crm.datalan.sk/esam/api/pfe" #endif }); #if !DEBUG container.Register <IMessageService>(c => new RedisMqServer(c.Resolve <IRedisClientsManager>())); container.Resolve <IMessageService>().RegisterHandler <WebEas.ServiceModel.Dto.LongOperationStatus>(m => { using (var redisClient = base.Resolve <IRedisClientsManager>().GetClient()) { var longOperationStatus = m.GetBody(); ProcessLongOperationStatus(longOperationStatus, redisClient, base.Resolve <IServerEvents>()); } return(null); }); container.Resolve <IMessageService>().Start(); #endif container.RegisterAutoWiredAs <CfeRepository, IRepositoryBase>("cfe").ReusedWithin(ReuseScope.Request); container.RegisterAutoWiredAs <BdsRepository, IRepositoryBase>("bds").ReusedWithin(ReuseScope.Request); //container.RegisterAutoWiredAs<DapRepository, IRepositoryBase>("dap").ReusedWithin(ReuseScope.Request); //container.RegisterAutoWiredAs<DmsRepository, IRepositoryBase>("dms").ReusedWithin(ReuseScope.Request); //container.RegisterAutoWiredAs<FinRepository, IRepositoryBase>("fin").ReusedWithin(ReuseScope.Request); //container.RegisterAutoWiredAs<OsaRepository, IRepositoryBase>("osa").ReusedWithin(ReuseScope.Request); container.RegisterAutoWiredAs <RegRepository, IRepositoryBase>("reg").ReusedWithin(ReuseScope.Request); //container.RegisterAutoWiredAs<RzpRepository, IRepositoryBase>("rzp").ReusedWithin(ReuseScope.Request); //container.RegisterAutoWiredAs<UctRepository, IRepositoryBase>("uct").ReusedWithin(ReuseScope.Request); //container.RegisterAutoWiredAs<VykRepository, IRepositoryBase>("vyk").ReusedWithin(ReuseScope.Request); //container.RegisterAutoWiredAs<MajRepository, IRepositoryBase>("maj").ReusedWithin(ReuseScope.Request); container.AddScoped <IPfeRepository, PfeRepository>(); var mse = new ServerEventsFeature() { LimitToAuthenticatedUsers = true, NotifyChannelOfSubscriptions = false, OnCreated = (sub, req) => { var session = req.SessionAs <EsamSession>(); if (!session.IsAuthenticated) { return; } if (session.Roles != null) { var key = "SynchronizaciaDAPToast:" + session.TenantId + ":" + session.UserId; var showed = GetCacheClient().Get <bool>(key); if (!showed) { if (session.Roles.Any(x => x.StartsWith("DAP") || x.StartsWith("FIN") || x.StartsWith("UCT"))) { var repository = HostContext.Resolve <IPfeRepository>(); repository.Session = session; var eSAMRezim = repository.GetNastavenieI("cfe", "eSAMRezim"); var isoZdroj = repository.GetNastavenieI("cfe", "ISOZdroj"); if (repository.GetNastavenieB("cfe", "PohladavkyDAP") && (eSAMRezim == 1 || isoZdroj > 0)) { var datumSynchro = repository.GetNastavenieT("dap", "SynchronizaciaDAP"); if (datumSynchro.HasValue) { sub.ConnectArgs["SynchronizaciaDAP"] = datumSynchro.Value.ToString("o"); } GetCacheClient().Set(key, true, DateTime.Today.AddDays(1)); } } } } }, /* * TODO: Synchronizacia s ISO * OnSubscribe = (sub) => * { * if (sub.UserId == "00000000-0000-0000-0000-000000000002") * { * var subSessionKey = SessionFeature.GetSessionKey(sub.SessionId); * var subSession = HostContext.Cache.Get<EsamSession>(subSessionKey); * var syncManager = new IsoSynchronizationManager(Resolve<IServerEvents>(), Resolve<IRedisClientsManager>()); * syncManager.ProcessQueue(subSession.TenantId); * } * }*/ }; Plugins.Add(mse); }
public override void Configure(Funq.Container container) { container.Register <ICacheClient>(new MemoryCacheClient()); }
public override void Configure(Funq.Container container) { container.Register <IDbConnectionFactory> (new OrmLiteConnectionFactory(":memory:", false, SqliteDialect.Provider)); }