public void Register(IToolContainer container) { // foreach (var stratagy in stratagies.Values) // { // stratagy.Register(container/*, ConfigurationScope*/); // } }
public void Register(IToolContainer container) { foreach (var registrationStratagy in stratagies) { registrationStratagy.Register(container); } }
// public static IToolContainer InstallData<T>(this IToolContainer container, Action<T> action) where T : DataAccess, new () // { //// container.Register(r => r.Service<T>().ToSelf().With(container)); //// var builder = container.Resolve<T>(); // var builder = (T)Activator.CreateInstance(typeof(T), container); // action(builder); // builder.Build(); // return container; // } public static IToolContainer InstallInjections(this IToolContainer container, Assembly assembly = null) { if (assembly == null) { assembly = Assembly.GetCallingAssembly(); } var attributeType = typeof(InjectAttribte); var types = assembly.GetTypes().Where(t => Attribute.IsDefined(t, attributeType)).ToArray(); foreach (var type in types) { var attribute = type.GetCustomAttributes(attributeType).First() as InjectAttribte; if (attribute != null) { var intefaces = type.GetInterfaces(); Type injectionType = type; if (injectionType.IsClass) { if (intefaces.Any()) { var serviceType = intefaces.FirstOrDefault(); container.Register(r => r.For(serviceType).To(injectionType).LifeTime(attribute.LifeTime)); } } if (injectionType.IsInterface) { container.Register(r => r.For(injectionType).ToSelf().LifeTime(attribute.LifeTime)); } } } return(container); }
public static IToolContainer InstallControllerFactory(this IToolContainer container) { var currentFactory = ControllerBuilder.Current.GetControllerFactory(); if (currentFactory == null || currentFactory.GetType() != typeof(ControllerFactory)) { ControllerBuilder.Current.SetControllerFactory(new ControllerFactory(container)); } return(container); }
public void Register(IToolContainer container) { // var sessionFactoryName = string.Format("SF_{0}", configurationScope ?? string.Empty); //// var sessionName = string.Format("session_{0}", configurationScope ?? string.Empty); // container.Register(r => r.For<ISessionFactory>().ToFactory(x => SessionFactory()).LifeTime(LifeTime.Singleton)); // container.Register(r => r.For<ISession>().ToFactory(x => // { // var c = container; //// var sfName = sessionFactoryName; // var factory = c.Resolve<ISessionFactory>(); // return factory.OpenSession(); // }).LifeTime(LifeTime)); }
public void Register(IToolContainer container) { // var respositoryName = string.Format("repository.{0}", Scope); // var sessionName = string.Format("session.{0}", Scope); // var hibernateSessionName = string.Format("hib.session.{0}", Scope); // var factoryName = string.Format("session.factory.{0}", Scope); // container.Register(r => r.For<ISessionFactory>().ToFactory(x => SessionFactoryConfiguration.BuildSessionFactory(sourceAssembly, connectionString)).Name(factoryName).LifeTime(LifeTime.Singleton)); // // container.Register(r => r.For<ISession>().ToFactory(x => // { // var c = container; // var factory = c.Resolve<ISessionFactory>(); // return factory.OpenSession(); // }).Name(hibernateSessionName).LifeTime(LifeTime.Transient)); // // container.Register(r => r.For<IDbSession>().To(SessionConfig.Type).Name(sessionName).DependsOn<ISession>(hibernateSessionName).LifeTime(StoreConfig.LifeTime)); // container.Register(r => r.For(typeof(IStore<>)).To(StoreConfig.Type).Name(respositoryName).DependsOn<IDbSession>(sessionName).LifeTime(StoreConfig.LifeTime)); }
public static IToolContainer InstallHibernateLogger(this IToolContainer container) { LoggerProvider.SetLoggersFactory(new HibernateLoggerFactory(container.Resolver)); return(container); }
public void Register(IToolContainer container) { // container.Register(r => r.For(userStoreInterface).To(userStoreClass).LifeTime(LifeTime.Transient)) // .Register(r => r.For(userManagerClass).ToSelf().LifeTime(LifeTime.Transient)); }
/// <summary> /// Constructor /// </summary> /// <param name="resolver"></param> public ControllerFactory(IToolContainer container) { this.container = container; }
public void Register(IToolContainer registrator) { registrationAction(registrator); }
public static IToolContainer InstallApiControllerFactory(this IToolContainer container) { GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerActivator), new WebCompositionRoot(container)); return(container); }
public SitemapManagerFactory(IToolContainer container) { this.container = container; }
public WebCompositionRoot(IToolContainer container) { this.container = container; }
// public static IToolContainer Register(this IToolContainer registrator, Action<IServiceBuilderFor> serviceAction) // { // var context = new ServiceConfiguration(); // // var builder = new ServiceBuilder(); // serviceAction(builder); // builder.Register(registrator); // return registrator; // } public static IToolContainer Component(this IToolContainer registrator, Action <IComponentSetup> componentAction) { return(registrator); }
public static IToolContainer InstallNative <T>(this IToolContainer container, Action <T> action) { action(container.GetContainer <T>()); return(container); }
public void Register(IToolContainer registrator) { // registrator.Register(context); }