public void Register(IContainerManager containerManager, CMS.Common.Runtime.ITypeFinder typeFinder)
 {
     foreach (var type in typeFinder.FindClassesOfType<ICommerceDbProvider>())
     {
         CommerceDbProviders.Providers.Add((ICommerceDbProvider)containerManager.Resolve(type));
     }
 }
Beispiel #2
0
 public void Register(IContainerManager containerManager, CMS.Common.Runtime.ITypeFinder typeFinder)
 {
     foreach (var type in typeFinder.FindClassesOfType<ITabPlugin>())
     {
         containerManager.AddComponent(typeof(ITabPlugin), type, type.FullName, ComponentLifeStyle.Transient);
     }
 }
        public void Register(IContainerManager containerManager, CMS.Common.Runtime.ITypeFinder typeFinder)
        {
            // Current instance providers
            containerManager.AddComponent(typeof(ICurrentInstanceProvider), typeof(ThreadScopeCurrentInstanceProvider), "ThreadScopeCurrentInstanceProvider", ComponentLifeStyle.Singleton);
            containerManager.AddComponent(typeof(ICurrentInstanceProvider), typeof(SiteAwareHttpCurrentInstanceProvider), "SiteAwareHttpCurrentInstanceProvider", ComponentLifeStyle.Transient);

            // Data folder factory
            containerManager.AddComponentInstance<DataFolderFactory>(DataFolderFactory.Current);

            // Instance intializers
            foreach (var type in typeFinder.FindClassesOfType<IInstanceInitializer>())
            {
                containerManager.AddComponent(typeof(IInstanceInitializer), type, type.FullName, ComponentLifeStyle.Transient);
            }

            // Repository and ICommerceDatabase
            var container = ((Kooboo.CMS.Common.Runtime.Dependency.Ninject.ContainerManager)containerManager).Container;

            container.Bind<CommerceInstance>()
                     .ToMethod(ctx => CommerceInstance.Current);

            container.Bind<ICommerceDatabase>()
                     .ToMethod(ctx =>
                     {
                         var instance = CommerceInstance.Current;
                         if (instance == null)
                             throw new InvalidOperationException("Cannot resolve ICommerceDatabase, because there's no commerce instance in the context.");

                         return instance.Database;
                     });

            container.Bind(typeof(IRepository<>)).To(typeof(CommerceRepository<>));
        }
 public void Register(IContainerManager containerManager, CMS.Common.Runtime.ITypeFinder typeFinder)
 {
     foreach (var type in typeFinder.FindClassesOfType<ICommerceDataSource>())
     {
         if (type.IsClass && !type.IsAbstract)
         {
             containerManager.AddComponent(typeof(ICommerceDataSource), type, type.FullName, ComponentLifeStyle.Transient);
         }
     }
 }
 public void Register(IContainerManager containerManager, CMS.Common.Runtime.ITypeFinder typeFinder)
 {
     foreach (var type in typeFinder.FindClassesOfType<IRuleParameterProvider>())
     {
         if (type != typeof(DefaultRuleParameterProvider))
         {
             var provider = Activator.CreateInstance(type) as IRuleParameterProvider;
             RuleParameterProviders.Providers.Add(provider);
         }
     }
 }
        public void Register(IContainerManager containerManager, CMS.Common.Runtime.ITypeFinder typeFinder)
        {
            containerManager.AddComponent(typeof(IMenuInjection), typeof(GlobalMenuInjection), "GlobalMenuInjection", ComponentLifeStyle.Singleton);
            containerManager.AddComponent(typeof(IMenuInjection), typeof(InstanceMenuInjection), "InstanceMenuInjection", ComponentLifeStyle.Singleton);

            foreach (var type in typeFinder.FindClassesOfType<IMenuInjection>())
            {
                if (typeof(CommerceMenuInjection).IsAssignableFrom(type)
                    && type != typeof(GlobalMenuInjection)
                    && type != typeof(InstanceMenuInjection))
                {
                    containerManager.AddComponent(typeof(IMenuInjection), type, type.FullName, ComponentLifeStyle.Transient);
                }
            }
        }
 static void RegisterActivities(IContainerManager containerManager, CMS.Common.Runtime.ITypeFinder typeFinder)
 {
     foreach (var activityType in typeFinder.FindClassesOfType<IActivity>())
     {
         if (activityType.IsClass && !activityType.IsAbstract)
         {
             containerManager.AddComponent(typeof(IActivity), activityType, activityType.FullName, ComponentLifeStyle.Transient);
         }
     }
 }