public static void Register(Container container) { container.RegisterAutoWiredAs<PlaceService, IPlaceService>().ReusedWithin(ReuseScope.Container); container.RegisterAutoWiredAs<HotelService, IHotelService>().ReusedWithin(ReuseScope.Container); container.RegisterAutoWiredAs<HotelPriceService, IHotelPriceService>().ReusedWithin(ReuseScope.Container); container.RegisterAutoWiredAs<FlightService, IFlightService>().ReusedWithin(ReuseScope.Container); }
/// <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 = "CFE"; base.Configure(container); this.SetConfig(new HostConfig { WsdlServiceNamespace = "http://schemas.webeas.sk/office/esam/office/1.0", SoapServiceName = "EsamOfficeCfe", #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 }); 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.RegisterAutoWiredAs <CfeRepository, IRepositoryBase>("cfe").ReusedWithin(ReuseScope.Request); container.AddScoped <ICfeRepository, CfeRepository>(); }
private static void RegisterInstances(Funq.Container container) { container.RegisterAutoWiredAs <ASEExceptionLogger, ILogger>(); container.RegisterAutoWiredAs <ContactManager, IContactManager>(); container.RegisterAutoWiredAs <CohortRulesProcessor, ICohortRulesProcessor>(); container.RegisterAutoWiredAs <NGManager, INGManager>(); }
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) { // Registering the dependencies that will be used during the application lifetime and by the service itself. container.RegisterAutoWiredAs<Configuration, IConfiguration>().ReusedWithin(ReuseScope.Container); container.RegisterAutoWiredAs<MayLilyMetadataSource, IMetadataSource>().ReusedWithin(ReuseScope.Container); container.RegisterAutoWiredAs<MayLilyContext, IDbMigrator>().ReusedWithin(ReuseScope.None); container.RegisterAutoWiredAs<MayLilyContext, IMayLilyContext>().ReusedWithin(ReuseScope.None); }
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); }
private void ConfigureAuth(Container container) { container.Register(GetUserSession).ReusedWithin(ReuseScope.Request); container.Register(GetUserProfile).ReusedWithin(ReuseScope.Request); container.RegisterAutoWiredAs<OrmLiteAuthRepository, IAuthRepository>().ReusedWithin(ReuseScope.Request); container.RegisterAutoWiredAs<OrmLiteAuthRepository, IUserAuthRepository>().ReusedWithin(ReuseScope.Request); var auth_providers = new IAuthProvider[] { new CredentialsAuthProvider() }; var auth_feature = new AuthFeature(() => new BoilerUserSession(), auth_providers) { HtmlRedirect = "/index.html" }; Plugins.Add(auth_feature); }
/// <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 ServerEventsFeature()); SetConfig(new HostConfig { DebugMode = AppSettings.Get("DebugMode", false), DefaultContentType = MimeTypes.Json, AddRedirectParamsToQueryString = true, }); 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(Container container) { Store = new DocumentStore { ConnectionStringName = "RavenDB" }; Store.Initialize(); IndexCreation.CreateIndexes(typeof(Vacancies_WithApplicantCount).Assembly, Store); container.Register<IDocumentStore>(c => Store); container.Register(c => c.Resolve<IDocumentStore>() .OpenSession()) .ReusedWithin(ReuseScope.Request); container.RegisterAutoWiredAs<VacancyService, IVacancyService>(); container.RegisterAutoWiredAs<TestService,ITestService>(); ControllerBuilder.Current.SetControllerFactory( new FunqControllerFactory(container)); LogManager.LogFactory = new ConsoleLogFactory(); }
/// <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) { //Config examples //this.Plugins.Add(new PostmanFeature()); //Plugins.Add(new CorsFeature()); 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 new FacebookAuthProvider(AppSettings), //Sign-in with Facebook new GithubAuthProvider(AppSettings), //Sign-in with GitHub OAuth Provider })); 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(); } Plugins.Add(new RazorFormat { LoadFromAssemblies = { typeof(CefResources).Assembly }, }); SetConfig(new HostConfig { DebugMode = true, EmbeddedResourceBaseTypes = { typeof(AppHost), typeof(CefResources) }, }); }
public void Does_AutoWire_Funq_types() { var container = new Container(); container.RegisterAutoWiredAs<Foo, IFoo>(); container.RegisterAutoWired<FunqTest>(); var test = container.Resolve<FunqTest>(); Assert.That(test.CtorFoo, Is.Not.Null); Assert.That(test.CtorFoo(), Is.Not.Null); Assert.That(test.FunqFoo, Is.Not.Null); Assert.That(test.FunqFoo(), Is.Not.Null); }
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); }
public void Does_AutoWire_MultiFunq_types() { var container = new Container(); container.RegisterAutoWiredAs<Foo, IFoo>(); container.RegisterAutoWiredAs<Bar, IBar>(); container.RegisterAutoWired<Test>(); var foo = container.Resolve<IFoo>(); Assert.That(foo, Is.Not.Null); var bar = container.Resolve<IBar>(); Assert.That(bar, Is.Not.Null); container.RegisterAutoWired<MultiFunqTest>(); var test = container.Resolve<MultiFunqTest>(); Assert.That(test.CtorFooBar, Is.Not.Null); Assert.That(test.CtorFooBar(new Foo()), Is.Not.Null); Assert.That(test.FunqFooBar, Is.Not.Null); Assert.That(test.FunqFooBar(new Foo()), Is.Not.Null); Assert.That(test.FunqTestFooBar, Is.Not.Null); Assert.That(test.FunqTestFooBar(new Test(), new Foo()), Is.Not.Null); }
void registerDependencies(Container container) { // ReuseScope.None disposes the Db connection. // Needed for Sql Server container.RegisterAutoWiredAs<Repository, IRepository>().ReusedWithin(ReuseScope.None); container.RegisterAutoWired<BaseService>().ReusedWithin(ReuseScope.None); container.RegisterAutoWired<HomeService>().ReusedWithin(ReuseScope.None); container.RegisterAutoWired<SearchService>().ReusedWithin(ReuseScope.None); container.RegisterAutoWiredAs<ProductsService, IProductsService>().ReusedWithin(ReuseScope.None); // not exposing this on PublicMvc //container.RegisterAutoWired<ProductsProcessorService>().ReusedWithin(ReuseScope.None); var connectionString = ConfigurationManager .ConnectionStrings["DiffStack"].ConnectionString; container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory( connectionString, SqlServerDialect.Provider ) ); }
public override void Configure(Container container) { SetConfig(new EndpointHostConfig() { EnableFeatures = Feature.All.Remove(Feature.Metadata), DefaultRedirectPath = "/default", GlobalResponseHeaders = { { "X-Powered-by", "Test" }, { "Server", "Test" } }, AllowJsonpRequests = true, }); StreamExtensions.GZipProvider = new NetGZipProvider(); StreamExtensions.DeflateProvider = new NetDeflateProvider(); container.Register<ICacheClient>(x => new PooledRedisClientManager("10.10.3.166:6379").GetCacheClient()); container.Register<Logger>(x => LogManager.GetLogger("MemoryLeakTestLog")); container.RegisterAutoWiredAs<BusinessRule, IBusinessRule>().ReusedWithin(ReuseScope.None); }
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("*****@*****.**") == null) { userAuthRepository.CreateUserAuth( new UserAuth {Email = "*****@*****.**", DisplayName = "Admin User"}, "admin"); } InitializeDatabase(container); }
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( ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString )); container.RegisterAutoWired<XpmsAuthProvider>().ReusedWithin(ReuseScope.Hierarchy); container.RegisterAutoWiredAs<Mailer, IMailer>().ReusedWithin(ReuseScope.Hierarchy); container.RegisterProcesses<AbstractProcess>(); container.RegisterValidators(typeof(SignupRequestValidator).Assembly); container.RegisterDataRecords<IRepoData>(typeof(AzureStorage).Assembly); }
/// <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 ServerEventsFeature()); InitializeAppSettings (); Plugins.Add (new RazorFormat { LoadFromAssemblies = { typeof(CefResources).Assembly }, }); SetConfig (new HostConfig { DebugMode = AppSettings.Get("DebugMode", false), DefaultContentType = MimeTypes.Json, AllowFileExtensions = { "jsx" }, EmbeddedResourceBaseTypes = { typeof(AppHost), typeof(CefResources) }, }); Routes.Add<NativeHostAction>("/nativehost/{Action}"); ServiceController.RegisterService(typeof(NativeHostService)); 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(Container container) { var dbFactory = new OrmLiteConnectionFactory( "Data Source=mydb.db;Version=3;", SqliteDialect.Provider); container.Register<IDbConnectionFactory>(dbFactory); container.RegisterAutoWiredAs<PlacesToVisitRepository, IPlacesToVisitRepository>(); container.Resolve<IPlacesToVisitRepository>().InitializeSchema(); _seedData.CreateUsers(container); _seedData.SeedPlaces(container.Resolve<IPlacesToVisitRepository>()); Plugins.Add(new PostmanFeature()); Plugins.Add(new CorsFeature()); Plugins.Add(new ValidationFeature()); Plugins.Add( new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new BasicAuthProvider() })); }
/// <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(); } }
/// <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) { //Config examples //this.Plugins.Add(new PostmanFeature()); //Plugins.Add(new CorsFeature()); InitializeAppSettings(); Plugins.Add(new RazorFormat { LoadFromAssemblies = { typeof(SharedEmbeddedResources).Assembly } }); SetConfig(new HostConfig { DebugMode = true, EmbeddedResourceBaseTypes = { typeof(AppHost), typeof(SharedEmbeddedResources) } }); 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(); } // This route is added using Routes.Add and ServiceController.RegisterService due to // using ILMerge limiting our AppHost : base() call to one assembly. // If two assemblies are used, the base() call searchs the same assembly twice due to the ILMerged result. Routes.Add<NativeHostAction>("/nativehost/{Action}"); ServiceController.RegisterService(typeof(NativeHostService)); }
public override void Configure(Container container) { JsConfig.DateHandler = JsonDateHandler.ISO8601; JsConfig.EmitCamelCaseNames = true; Plugins.Add(new RazorFormat()); SetConfig(new EndpointHostConfig { GlobalResponseHeaders = { { "Access-Control-Allow-Origin", "*" }, { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" }, { "Access-Control-Allow-Headers", "Content-Type" }, }, DebugMode = true, DefaultContentType = ContentType.Json, AllowJsonpRequests = true, DefaultRedirectPath = "/stats", MetadataRedirectPath = "/stats", MetadataCustomPath = "/stats" }); container.RegisterAutoWiredAs<TripThruPartnerGateway.InitPartnerService, InitPartnerService>(); var configuration = JsonSerializer.DeserializeFromString<TripThruCore.PartnerConfiguration>( File.ReadAllText("~/PartnerConfiguration.txt".MapHostAbsolutePath())); //Authentication Plugins.Add( new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new CustomCredentialsAuthProvider( new Dictionary<string, string>(){ {"tripthru", "optimize"} }, configuration.host.virtualPath ) } ) { HtmlRedirect = "~/login.html", ServiceRoutes = new Dictionary<Type, string[]> { { typeof(AuthService), new[]{"/auth", "/auth/{provider}"}}, { typeof(AssignRolesService), new[]{"/assignroles"} }, { typeof(UnAssignRolesService), new[]{"/unassignroles"} }, } } ); //Unhandled exceptions //Handle Exceptions occurring in Services: this.ServiceExceptionHandler = (request, exception) => { //log your exceptions here Logger.LogDebug("ServiceExceptionHandler : " + exception.Message, exception.StackTrace); //call default exception handler or prepare your own custom response return DtoUtils.HandleException(this, request, exception); }; //Handle Unhandled Exceptions occurring outside of Services, //E.g. in Request binding or filters: this.ExceptionHandler = (req, res, operationName, ex) => { Logger.LogDebug("ExceptionHandler : " + ex.Message, ex.StackTrace); res.Write("Error: {0}: {1}".Fmt(ex.GetType().Name, ex.Message)); res.EndServiceStackRequest(skipHeaders: true); }; /** * Note: since Mono by default doesn't have any trusted certificates is better to validate them in the app domain * than to add them manually to the deployment server */ System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => { return true; //Todo: fix this to actually validate the certificates }; //Init using (var initPartners = container.Resolve<InitPartnerService>()) { initPartners.Any(null); } }
/// <summary> /// Configure application settings and configuration. /// </summary> /// <param name="container">The DI / IoC container.</param> private void ConfigureApplication(Container container) { // Set application settings AppSettings = new AppSettings(); container.Register<IAppSettings>(AppSettings); // Set configuration parameters AppConfig = new AppConfig(AppSettings); // TODO: Inject AppConfig // Configure logger injection container.RegisterAutoWiredAs<DebugOutputLogger, ILogger>(); // Set the service controller instance container.Register<IServiceController>(new RestServiceController("http://localhost:8888")); // Set the game controller instance ActorGameController = new ActorGameController("akka-dotnet-dragons", container.Resolve<IServiceController>(), container.Resolve<ILogger>()); container.Register<IGameController>(ActorGameController); }
public override void Configure(Container container) { container.RegisterAutoWiredAs<RedisClient, IRedisClient>(); }
/// <summary> /// The configure. /// </summary> /// <param name="container"> /// The container. /// </param> public override void Configure(Container container) { container.RegisterAutoWiredAs<FileRepository, IRepository<File>>(); }
/// <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(Container container) { //Plugins.RemoveAll(x => x is MetadataFeature); Plugins.Add(new CorsFeature()); Plugins.Add(new SwaggerFeature()); Plugins.Add(new ValidationFeature()); Plugins.Add(new PostmanFeature()); var config = new AppConfig(); config.ReadWriteApiKeys.AddRange(ConfigurationManager.AppSettings["apiKeys"].Split(new[] {','})); container.Register(config); GlobalRequestFilters.Add((req, res, requestDto) => { if (requestDto.GetType() != typeof (CreateCrawler) && req.Verb.ContainsAny(new[] {"DELETE", "PUT", "POST"})) { var keyValidator = new ApiKeyAttribute(); keyValidator.Execute(req, res, requestDto); } }); SetConfig(new HostConfig { DefaultRedirectPath = "/swagger-ui/" }); container.RegisterAutoWiredAs<UriRequestRunner, IScraperRequestRunner>(); container.RegisterAutoWiredAs<WebScraper, IScraper>(); container.RegisterAutoWiredAs<CrawlWebRunner, ICrawlRunner>(); container.RegisterAutoWiredTypes(new[] {typeof (CrawlerValidator), typeof (LeagueEngine), typeof (LeagueServices)}); container.RegisterValidators(typeof(CreateSeasonValidator).Assembly); //container.RegisterAutoWired<GameEngine>().ReusedWithin(ReuseScope.Container); container.Register<IDbConnectionFactory>( new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/leaguedata.sqlite"), SqliteDialect.Provider)); //container.Register<IDbConnectionFactory>( // new OrmLiteConnectionFactory( // "Server=127.0.0.1;Port=5432;User Id=postgres;Password=test123;Database=testDb;Pooling=true;MinPoolSize=0;MaxPoolSize=200", // PostgreSqlDialect.Provider)); using (var db = container.Resolve<IDbConnectionFactory>().Open()) { db.CreateTableIfNotExists<Season>(); db.CreateTableIfNotExists<Division>(); db.CreateTableIfNotExists<Server>(); db.CreateTableIfNotExists<Crawler>(); db.CreateTableIfNotExists<Participant>(); db.CreateTableIfNotExists<Game>(); db.CreateTableIfNotExists<Rune>(); } OrmLiteConfig.InsertFilter = (dbCmd, row) => { var auditRow = row as IAudit; if (auditRow != null) auditRow.CreatedDate = auditRow.ModifiedDate = DateTime.UtcNow; }; OrmLiteConfig.UpdateFilter = (dbCmd, row) => { var auditRow = row as IAudit; if (auditRow != null) auditRow.ModifiedDate = DateTime.UtcNow; }; container.Resolve<LeagueEngine>().Start(); }
public override void Configure(Container container) { Plugins.Add(new CorsFeature()); Plugins.Add(new ValidationFeature()); Plugins.Add(new PostmanFeature()); // Build path for portability between win/linux var dbPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) .CombineWith("data") .CombineWith("leaguedata.sqlite"); // SQLite container.Register<IDbConnectionFactory>(new OrmLiteConnectionFactory(dbPath, SqliteDialect.Provider)); container.Register<IKeys>(new ApiKeys(AppSettings.GetList("apiKeys"))); // API Keys container.RegisterAutoWiredAs<MlbBioProvider, IBioData>(); // Bios from MLB container.RegisterAutoWiredAs<MlbStatProvider, IStatData>(); // Stats from MLB container.RegisterAutoWiredAs<FunqServiceFactory, IServiceFactory>(); // Service Factory container.RegisterAutoWired<Services>(); container.RegisterAutoWired<LeagueEngine>(); // Validators container.RegisterValidators(typeof(TeamValidator).Assembly); // Include type info for update options. JsConfig<BioUpdateOptions>.IncludeTypeInfo = true; JsConfig<StatUpdateOptions>.IncludeTypeInfo = true; JsConfig<TeamUpdateOptions>.IncludeTypeInfo = true; JsConfig.EmitCamelCaseNames = true; OrmLiteConfig.InsertFilter = (dbCmd, row) => { var auditRow = row as IAudit; if (auditRow != null) auditRow.Created = auditRow.Modified = DateTime.UtcNow; }; // Update filter for IAudit OrmLiteConfig.UpdateFilter = (dbCmd, row) => { var auditRow = row as IAudit; if (auditRow != null) auditRow.Modified = DateTime.UtcNow; }; // Setup tables using (var db = container.Resolve<IDbConnectionFactory>().Open()) { db.CreateTableIfNotExists( typeof(Team), typeof(Player), typeof(Division), typeof(Teamate), typeof(DivisionalPlayer), typeof(LeagueEvent), typeof(GameLog), typeof(PlayerTotals), typeof(TeamTotals), typeof(Setting) ); } // Log any exception coming out of the services. ServiceExceptionHandlers.Add((httpReq, request, exception) => { LogManager.GetLogger(request.GetType()).Error($"{request.ToJson()}|{exception}"); return null; // continues default error handling }); var game = container.Resolve<LeagueEngine>(); game.Start(); }
/// <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 { HandlerFactoryPath = "api", DefaultContentType = "application/json", WsdlServiceNamespace = "http://schemas.servicestack.net/types", DebugMode = false, UseHttpsLinks = false }); var appSettings = new AppSettings(); Plugins.Add(new SwaggerFeature()); Plugins.Add(new ValidationFeature()); Plugins.Add(new CorsFeature()); Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new BasicAuthProvider(), //Sign-in with HTTP Basic Auth new CredentialsAuthProvider { SkipPasswordVerificationForInProcessRequests = true }, new GoogleOAuth2Provider(appSettings), //Sign-in with Google OAuth2 Provider })); //Provide service for new users to register so they can login with supplied credentials. Plugins.Add(new RegistrationFeature()); /* IOC Registrations */ container.RegisterAutoWiredAs<SimpleDbClient, ISimpleDbClient>(); container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory(container.Resolve<ISimpleDbClient>().GetAppSetting("ResourceModelStore"), MySqlDialect.Provider)); container.RegisterAutoWiredAs<OrmLiteDatabaseRepository, IResourceModelRepository>(); var authRepo = CreateOrmLiteAuthRepo(container, appSettings); try { authRepo.CreateUserAuth(new CustomUserAuth { Custom = "CustomUserAuth", DisplayName = "Credentials", FirstName = "First", LastName = "Last", FullName = "First Last", Email = "*****@*****.**", }, "test"); authRepo.CreateUserAuth(new CustomUserAuth { Custom = "CustomUserAuth", DisplayName = "Credentials", FirstName = "First", LastName = "Last", FullName = "First Last", UserName = "******", }, "test"); } catch (Exception) { }//Create your own custom User table using (var db = container.Resolve<IDbConnectionFactory>().Open()) db.DropAndCreateTable<UserTable>(); Plugins.Add(new RequestLogsFeature()); ////Error Handling //ServiceExceptionHandlers.Add((httpReq, request, exception) => //{ // return DtoUtils.CreateErrorResponse(request, exception); //}); //The IUserAuthRepository is used to store the user credentials etc. //Implement this interface to adjust it to your app's data storage UncaughtExceptionHandlers.Add((req, res, operationName, ex) => { res.Write(string.Format("Exception {0}", ExceptionHelper.GetExceptionMessages(ex))); res.Write(string.Format("Stack Trace {0}", ExceptionHelper.GetStackTraces(ex))); res.EndRequest(true); }); }
public void Register(Container container) { container.RegisterAutoWiredAs<WebClientProxy, IWebClientProxy>().ReusedWithin(ReuseScope.Request); }
/// <summary> /// // Configure ServiceStack database connections. /// </summary> /// <param name="container">The container.</param> private void ConfigureDataConnection(Container container) { container.RegisterAutoWiredAs<Echo, IEcho>(); // ... }
public void TestFixtureSetUp() { container = new Container(); container.Register<IDbConnectionFactory>( new OrmLiteConnectionFactory(":memory:", false, SqliteDialect.Provider)); container.RegisterAutoWiredAs<RockstarRepository, IRockstarRepository>(); container.RegisterAutoWired<SimpleService>(); using (var db = container.Resolve<IDbConnectionFactory>().Open()) { db.DropAndCreateTable<Rockstar>(); db.InsertAll(SeedData); } }