public override void Configure(Funq.Container container) { container.Register <IDbConnectionFactory>( c => new OrmLiteConnectionFactory("~/App_Data/db.sqlite".MapHostAbsolutePath(), SqliteDialect.Provider) { ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current) }); container.RegisterAutoWired <JournalService>(); container.RegisterAutoWired <SessionService>(); using (var db = container.Resolve <IDbConnectionFactory>().Open()) { db.DropAndCreateTable <Journal>(); db.DropAndCreateTable <Session>(); db.DropAndCreateTable <Task>(); db.DropAndCreateTable <JournalNote>(); db.DropAndCreateTable <SessionNote>(); //Seed Lists db.InsertAll(SeedData.JournalSeed); db.InsertAll(SeedData.JournalNoteSeed); db.InsertAll(SeedData.SessionSeed); db.InsertAll(SeedData.TaskSeed); db.InsertAll(SeedData.SessionNoteSeed); } }
public override void Configure(Funq.Container container) { container.RegisterAutoWired <PlayersRepository>(); Plugins.Add(new ValidationFeature()); container.RegisterValidators(typeof(AppHost).Assembly); }
public override void Configure(Funq.Container container) { ServiceStack.Text.JsConfig.DateHandler = ServiceStack.Text.JsonDateHandler.ISO8601; this.Config.DebugMode = true; this.SetConfig(new EndpointHostConfig { DefaultRedirectPath = "/default" }); this.Plugins.Add(new RazorFormat()); container.Register <ICacheClient>(new MemoryCacheClient()); container.Register <MySqlConnectionFactory> (new MySqlConnectionFactory()); container.RegisterAutoWired <NameRepository> (); container.RegisterAutoWired <ValidatorFactory> (); this.ServiceExceptionHandler = (IHttpRequest httpReq, object request, Exception exception) => { Console.Error.WriteLine("{0}\n\n-----\n\n{1}", request, exception); return(ServiceStack.ServiceHost.DtoUtils.HandleException(this, request, exception)); }; }
public override void Configure(Funq.Container container) { //Confiture our application //IKernel kernel = new StandardKernel(); //kernel.Bind<TrackedDataRepository>().ToSelf(); //similar to funq, singleton. Class resolved to itself //container.Adapter = new NinjectContainerAdapter(kernel); //Authentication configuration - iOC container Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new BasicAuthProvider(), new TwitterAuthProvider(new AppSettings()) })); Plugins.Add(new RegistrationFeature()); //registration for new user Plugins.Add(new ValidationFeature()); container.RegisterValidators(typeof(EntryService).Assembly); //configure validators Plugins.Add(new RequestLogsFeature()); //enable request logs feature, a user with Admin privilages is needed Plugins.Add(new RazorFormat()); container.Register <ICacheClient>(new MemoryCacheClient()); //cache client // can set up Redis/Azure //Redis container.Register<IRedisClientManager>(c => new PooledRedisClientManager(redis client path)); //container.Register<ICacheClient>(c =>(ICacheClient)c.Resolve<IRedisClientManager>().GetCacheClient(); < resolve to cache client Redis' client. var userRepository = new InMemoryAuthRepository(); //in memory auth repository container.Register <IUserAuthRepository>(userRepository); //add a user string hash; string salt; new SaltedHash().GetHashAndSaltString("password", out hash, out salt); userRepository.CreateUserAuth(new UserAuth { Id = 1, DisplayName = "JoeUser", Email = "*****@*****.**", UserName = "******", FirstName = "Joe", LastName = "User", PasswordHash = hash, salt = salt, Roles = new List <string> { RoleNames.Admin } // have to have this role in order to call AssignRoles, UnAssignRoles default services //Roles = new List<string> { "User" },//this is Role Authorization //Permissions = new List<string> {"GetStatus"} //this is Permission Authorization }, "password"); //user is created in the repository var dbConnectionFactory = new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/data.txtx"), SqlliteDialect.Provider) { ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current); //enables any calls through ORM to be profiled. }; container.Register <IDbConnectionFactory>(dbConnectionFactory) //anywhere you want to use dbConnectionFactory, Funq will automatically populate this container.RegisterAutoWired <TrackedDataRepository>(); //Autowiring services and auto inject any public properties, SINGLETON by default //You can set the scope with ReusedWIthin LogManager.LogFactory = new EventLogFactory("ProteinTracker.Logging", "Application"); //name //source SetConfig(new EndpointHostConfig { DebugMode = true }); container.Register <IRedisClientsManager>(new PooledRedisClientManager("localhost:6379")); //default redis port var mqService = new RedisMqServer(container.Resolve <IRedisClientsManager>()); mqService.RegisterHandler <Entry>(ServiceController.ExecuteMessage); //executs the service that handles the Entry message //listens for Entry messages mqSerice.Start(); //start listening for messages }
public override void Configure(Funq.Container container) { container.RegisterAutoWired <ExampleService>(); container.RegisterAutoWired <BusinessLogic>(); container.RegisterAutoWiredAs <BusinessLogic, IBusinessLogic>(); }