private static void InitializeContainer(Container container)
        {
            var pluginDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Bin\Gadgets");

            var pluginAssemblies =
                from file in new DirectoryInfo(pluginDirectory).GetFiles()
                where file.Extension == ".dll"
                select Assembly.LoadFile(file.FullName);

            var pluginTypes =
                (from dll in pluginAssemblies
                from type in dll.GetExportedTypes()
                where typeof (IGadget).IsAssignableFrom(type)
                where !type.IsAbstract
                where !type.IsGenericTypeDefinition
                select type).ToList();

            container.RegisterAll<IGadget>(pluginTypes);

            foreach (var pluginType in pluginTypes)
            {
                container.Register(pluginType);
            }

            // For instance:
            // container.Register<IUserRepository, SqlUserRepository>();
        }
Exemple #2
0
        public static void RegisterPlugins <TImplements, TExport>(this Container container,
                                                                  IEnumerable <Assembly> assemblies, Lifestyle lifestyle = null) where TExport : class
        {
            var pluginTypes = GetTypes <TImplements>(assemblies).ToArray();

            HandleLifestyle <TExport>(container, lifestyle, pluginTypes);
            container.RegisterAll <TExport>(pluginTypes);
        }
 public void GetServices_ReturnsInstancesOfService()
 {
     var container = new Container();
     container.RegisterAll<IFakeMultipleServices>(typeof(FakeMultipleService1), typeof(FakeMultipleService2), typeof(FakeMultipleService3));
     container.Verify();
     var resolver = new WebApiDependencyResolver(container);
     var services = resolver.GetServices(typeof(IFakeMultipleServices)).ToArray();
     services.ShouldNotBeNull();
     services.Length.ShouldEqual(3);
     var serviceTypes = services.Select(x => x.GetType()).ToArray();
     serviceTypes.ShouldContain(typeof(FakeMultipleService1));
     serviceTypes.ShouldContain(typeof(FakeMultipleService2));
     serviceTypes.ShouldContain(typeof(FakeMultipleService3));
 }
        /// <summary>
        /// Discovers any IEnumerable dependencies of the specified type and attempts to register them.
        /// </summary>
        /// <param name="concreteType">Concrete type for which the dependencies should be discovered
        /// and registered</param>
        /// <param name="container">SimpleInjector container in which the dependencies should be registered.</param>
        /// <param name="options">Options to apply to the discovery and registration process.</param>
        public void RegisterDependencies(Type concreteType, Container container, IAutoRegistrationOptions options)
        {
            foreach (var ctor in concreteType.GetConstructors().Where((x) => x.IsPublic))
            {
                foreach (var param in ctor.GetParameters().Where((x) => typeof(System.Collections.IEnumerable).IsAssignableFrom(x.ParameterType)))
                {
                    var genericArgType = param.ParameterType.GenericTypeArguments.FirstOrDefault();

                    if (genericArgType != null 
                     && genericArgType.IsInterface 
                     && options.AutoRegistrationEnabledProvider.IsAutoRegistrationEnabled(genericArgType))
                    {
                        container.RegisterAll(genericArgType, options.ImplementationProvider.GetConcreteImplementionsOf(genericArgType));
                    }
                }
            }
        }
        internal void InitContainer()
        {
            var assembly = typeof(IOptionsDialogWatcher).Assembly;
            var exportedTypes = assembly.GetExportedTypes();
            var classes = exportedTypes.Where(t => t.IsClass);
            var interfaces = exportedTypes.Where(t => t.IsInterface);

            var registrations = from @interface in interfaces
                                let types = classes.Where(@interface.IsAssignableFrom)
                                where types.Count() == 1
                                select new
                                {
                                    Interface = @interface,
                                    Implementation = types.First()
                                };

            _container = new Container();
            _container.RegisterAll<IWindowModifier>(classes.Where(typeof(IWindowModifier).IsAssignableFrom));
            _container.RegisterWithContext(CyclicWorkerContexts);
            registrations.ToList().ForEach(r => _container.Register(r.Interface, r.Implementation));
        }
        private static Container Bootstrap()
        {
            var container = new Container();

            // register database types
            container.Register<IDatabaseInitializer<UCosmicContext>, BrownfieldInitializer>();
            container.Register<ISeedData, BrownfieldSeeder>();
            container.Register<UCosmicContext>();
            container.Register<IWrapDataConcerns, DataConcernsWrapper>();
            container.RegisterInitializer<UCosmicContext>(container.InjectProperties);

            // register browsers
            container.RegisterSingle(() => new ChromeDriver(GetChromeDriverDirectory()));
            container.RegisterSingle(() => new InternetExplorerDriver());
            container.RegisterSingle(() => new FirefoxDriver());
            var browsers = AllBrowsers(container);
            container.RegisterAll(browsers);

            // register other stuff
            container.Register<IManageConfigurations, DotNetConfigurationManager>();

            container.Verify();
            return container;
        }
Exemple #7
0
        //private static void RegisterAllPersisters()
        //{
        //    var baseType = typeof(CommandBase);

        //    var allCommands =
        //       AppDomain.CurrentDomain.GetAssemblies()
        //           .SelectMany(x => x.GetTypes())
        //           .Where(baseType.IsAssignableFrom)
        //           .Where(x => !x.IsAbstract)
        //           .Distinct()
        //           .ToArray();

        //    foreach (var command in allCommands)
        //    {
        //        if (command.IsGenericType)
        //        {

        //            // command.GetGenericArguments()[0].GetGenericParameterConstraints()
        //            // go throught all of that type and find the icommandsaves for it!
        //            var x = command.GetGenericParameterConstraints();
        //        }
        //        else
        //        {
        //            var saverType = typeof(ICommandSave<>).MakeGenericType(command);

        //            var allCommandSavers =
        //                AppDomain.CurrentDomain.GetAssemblies()
        //                    .SelectMany(x => x.GetTypes())
        //                    .Where(saverType.IsAssignableFrom)
        //                    .Where(x => !x.IsAbstract)
        //                    .Distinct()
        //                    .ToArray();
        //        }
        //    }
        //}

        private static void AddInterfaceForEachDerivedType(
            Container container,
            Type baseType,
            Type interfaceType)
        {
            var allTypesDerivedFromBase =
                AppDomain.CurrentDomain.GetAssemblies()
                    .SelectMany(x => x.GetTypes())
                    .Where(baseType.IsAssignableFrom)
                    .Where(x => !x.IsAbstract)
                    .Distinct()
                    .ToArray();

            var genericInterface = interfaceType.GetGenericTypeDefinition();

            foreach (var concrete in allTypesDerivedFromBase)
            {
                var concreteInterface = genericInterface.MakeGenericType(concrete);
                Trace.Write("Interface " + concreteInterface.ToString());

                if (!concrete.IsGenericType)
                {

                    var concreteImplementations = AppDomain.CurrentDomain.GetAssemblies()
                        .SelectMany(x => x.GetTypes())
                        .Where(x => x.GetInterfaces().Any())
                        .Where(concreteInterface.IsAssignableFrom)
                        .Distinct()
                        .ToList();

                    if (concreteImplementations.Any())
                    {
                        Trace.WriteLine(" implemented by:");
                        foreach (var impl in concreteImplementations)
                        {
                            Trace.WriteLine("-> " + impl.ToString());
                        }

                        container.RegisterAll(concreteInterface, concreteImplementations);
                    }
                    else
                    {
                        Trace.WriteLine(" has not implementations.");
                    }

                }
                else
                {
                    Trace.WriteLine("'s generic type param is itself generic and must be registered manually.");
                }
            }
        }
        public static void SetUp(Container container)
        {
            bool securityTrimmingEnabled = false;
            bool enableLocalization = true;
            string absoluteFileName = HostingEnvironment.MapPath("~/Mvc.sitemap");
            TimeSpan absoluteCacheExpiration = TimeSpan.FromMinutes(5);
            string[] includeAssembliesForScan = new string[] { "$AssemblyName$" };

            // Extension to allow resolution of arrays by GetAllInstances (natively based on IEnumerable).
            // source from: https://simpleinjector.codeplex.com/wikipage?title=CollectionRegistrationExtensions
            AllowToResolveArraysAndLists(container);

            var currentAssembly = typeof(MvcSiteMapProviderContainerInitializer).Assembly;
            var siteMapProviderAssembly = typeof(SiteMaps).Assembly;
            var allAssemblies = new Assembly[] { currentAssembly, siteMapProviderAssembly };
            var excludeTypes = new Type[]
                {
                    typeof (SiteMapNodeVisibilityProviderStrategy),
                    typeof (SiteMapXmlReservedAttributeNameProvider),
                    typeof (SiteMapBuilderSetStrategy),
                    typeof (ControllerTypeResolverFactory),

                    // Added 2013-06-28 by eric-b to avoid default singleton registration:
                    typeof(XmlSiteMapController),

                    // Added 2013-06-28 by eric-b for SimpleInjector.Verify method:
                    typeof(PreservedRouteParameterCollection),
                    typeof(MvcResolver),
                    typeof(MvcSiteMapProvider.SiteMap),
                    typeof(MetaRobotsValueCollection),
                    typeof(RoleCollection),
                    typeof(SiteMapPluginProvider),
                    typeof(ControllerTypeResolver),
                    typeof(RouteValueDictionary),
                    typeof(AttributeDictionary)
                };
            var multipleImplementationTypes = new Type[]
                {
                    typeof (ISiteMapNodeUrlResolver),
                    typeof (ISiteMapNodeVisibilityProvider),
                    typeof (IDynamicNodeProvider)
                };

            // Single implementations of interface with matching name (minus the "I").
            CommonConventions.RegisterDefaultConventions(
                (interfaceType, implementationType) => container.RegisterSingle(interfaceType, implementationType),
                new Assembly[] { siteMapProviderAssembly },
                allAssemblies,
                excludeTypes,
                string.Empty);

            // Multiple implementations of strategy based extension points
            CommonConventions.RegisterAllImplementationsOfInterfaceSingle(
                (interfaceType, implementationTypes) => container.RegisterAll(interfaceType, implementationTypes),
                multipleImplementationTypes,
                allAssemblies,
                new Type[0],
                "^Composite");

            container.Register<XmlSiteMapController>();

            // Visibility Providers
            container.RegisterSingle<ISiteMapNodeVisibilityProviderStrategy>(() =>
                                                                       new SiteMapNodeVisibilityProviderStrategy(
                                                                           container.GetAllInstances
                                                                               <ISiteMapNodeVisibilityProvider>().
                                                                               ToArray(), string.Empty));

            // Pass in the global controllerBuilder reference
            container.RegisterSingle<ControllerBuilder>(() => ControllerBuilder.Current);

            container.RegisterSingle<IControllerBuilder, ControllerBuilderAdaptor>();

            container.RegisterSingle<IBuildManager, BuildManagerAdaptor>();

            container.RegisterSingle<IControllerTypeResolverFactory>(() =>
                                                               new ControllerTypeResolverFactory(new string[0],
                                                                                                 container.GetInstance
                                                                                                     <IControllerBuilder
                                                                                                     >(),
                                                                                                 container.GetInstance
                                                                                                     <IBuildManager>()));

            // Configure Security
            container.RegisterSingle<AuthorizeAttributeAclModule>(() => new AuthorizeAttributeAclModule(
                                                                      container.GetInstance<IMvcContextFactory>(),
                                                                      container.GetInstance<IObjectCopier>(),
                                                                      container.GetInstance<IControllerDescriptorFactory>(),
                                                                      container.GetInstance<IControllerBuilder>(),
                                                                      container.GetInstance<IAuthorizeAttributeBuilder>(),
                                                                      container.GetInstance<IGlobalFilterProvider>()));

            container.RegisterAll<IAclModule>(typeof(AuthorizeAttributeAclModule), typeof(XmlRolesAclModule));
            container.RegisterSingle<IAclModule>(() => new CompositeAclModule(container.GetAllInstances<IAclModule>().ToArray()));

            // Setup cache
            #if NET35
            container.RegisterSingleOpenGeneric(typeof(ICacheProvider<>), typeof(AspNetCacheProvider<>));
            container.RegisterSingle<ICacheDependency>(() => new AspNetFileCacheDependency(absoluteFileName));
            #else
            container.RegisterSingle<System.Runtime.Caching.ObjectCache>(() => System.Runtime.Caching.MemoryCache.Default);
            container.RegisterSingleOpenGeneric(typeof(ICacheProvider<>), typeof(RuntimeCacheProvider<>));
            container.RegisterSingle<ICacheDependency>(() => new RuntimeFileCacheDependency(absoluteFileName));
            #endif
            container.RegisterSingle<ICacheDetails>(() => new CacheDetails(absoluteCacheExpiration, TimeSpan.MinValue, container.GetInstance<ICacheDependency>()));

            // Configure the visitors
            container.RegisterSingle<ISiteMapNodeVisitor, UrlResolvingSiteMapNodeVisitor>();

            // Register the sitemap builder
            container.RegisterSingle<ISiteMapXmlReservedAttributeNameProvider>(
                () => new SiteMapXmlReservedAttributeNameProvider(new string[0]));

            container.RegisterSingle<IXmlSource>(() => new FileXmlSource(absoluteFileName));

            container.RegisterSingle<XmlSiteMapBuilder>(() =>
                                                  new XmlSiteMapBuilder(
                                                      container.GetInstance<IXmlSource>(),
                                                      container.GetInstance<ISiteMapXmlReservedAttributeNameProvider>(),
                                                      container.GetInstance<INodeKeyGenerator>(),
                                                      container.GetInstance<IDynamicNodeBuilder>(),
                                                      container.GetInstance<ISiteMapNodeFactory>(),
                                                      container.GetInstance<ISiteMapXmlNameProvider>()
                                                      ));

            container.RegisterSingle<ReflectionSiteMapBuilder>(() =>
                                                         new ReflectionSiteMapBuilder(
                                                             includeAssembliesForScan,
                                                             new string[0],
                                                             container.GetInstance
                                                                 <ISiteMapXmlReservedAttributeNameProvider>(),
                                                             container.GetInstance<INodeKeyGenerator>(),
                                                             container.GetInstance<IDynamicNodeBuilder>(),
                                                             container.GetInstance<ISiteMapNodeFactory>(),
                                                             container.GetInstance<ISiteMapCacheKeyGenerator>()
                                                             ));

            container.RegisterAll<ISiteMapBuilderSet>(ResolveISiteMapBuilderSets(container, securityTrimmingEnabled, enableLocalization));
            container.RegisterSingle<ISiteMapBuilderSetStrategy>(() => new SiteMapBuilderSetStrategy(container.GetAllInstances<ISiteMapBuilderSet>().ToArray()));

            container.RegisterSingle<VisitingSiteMapBuilder>();
        }
        public RegisterAll3Generic()
        {
            var container = new Container();

            container.RegisterAll<ICommon>(new List<Type> { typeof(CommonImpl1), typeof(CommonImpl2) });
        }
Exemple #10
0
 /// <summary>
 /// Initializes the composition of the <see cref="DazzleDatabase"/>
 /// </summary>
 private void Initialize()
 {
     // Composition root.
     container = new Container();
     container.Register<Grammar, DqlGrammar>();
     container.Register<LanguageData>();
     container.Register<IQueryProcessor, LevelDbQueryProcessor>();
     container.Register<DqlQueryReader>();
     container.Register<DqlQueryPlanBuilder>();
     container.RegisterAll(typeof(IOperationBuilder), new Type[] { typeof(SelectOperationBuilder) });
 }
        public static void SetUp(Container container)
        {
            bool enableLocalization = true;
            string absoluteFileName = HostingEnvironment.MapPath("~/Mvc.sitemap");
            TimeSpan absoluteCacheExpiration = TimeSpan.FromMinutes(5);
            bool visibilityAffectsDescendants = true;
            bool useTitleIfDescriptionNotProvided = true;
            #if Demo
            // Settings for MvcMusicStore demo: don't copy into your project
            bool securityTrimmingEnabled = true;
            string[] includeAssembliesForScan = new string[] { "Mvc Music Store" };
            #else
            bool securityTrimmingEnabled = false;
            string[] includeAssembliesForScan = new string[] { "$AssemblyName$" };
            #endif

            // Extension to allow resolution of arrays by GetAllInstances (natively based on IEnumerable).
            // source from: https://simpleinjector.codeplex.com/wikipage?title=CollectionRegistrationExtensions
            AllowToResolveArraysAndLists(container);

            var currentAssembly = typeof(MvcSiteMapProviderContainerInitializer).Assembly;
            var siteMapProviderAssembly = typeof(SiteMaps).Assembly;
            var allAssemblies = new Assembly[] { currentAssembly, siteMapProviderAssembly };
            var excludeTypes = new Type[]
            {
                // Use this array to add types you wish to explicitly exclude from convention-based
                // auto-registration. By default all types that either match I[TypeName] = [TypeName] or
                // I[TypeName] = [TypeName]Adapter will be automatically wired up as long as they don't
                // have the [ExcludeFromAutoRegistrationAttribute].
                //
                // If you want to override a type that follows the convention, you should add the name
                // of either the implementation name or the interface that it inherits to this list and
                // add your manual registration code below. This will prevent duplicate registrations
                // of the types from occurring.

                // Example:
                // typeof(SiteMap),
                // typeof(SiteMapNodeVisibilityProviderStrategy)
            };
            var multipleImplementationTypes = new Type[]
            {
                typeof(ISiteMapNodeUrlResolver),
                typeof(ISiteMapNodeVisibilityProvider),
                typeof(IDynamicNodeProvider)
            };

            // Matching type name (I[TypeName] = [TypeName]) or matching type name + suffix Adapter (I[TypeName] = [TypeName]Adapter)
            // and not decorated with the [ExcludeFromAutoRegistrationAttribute].
            CommonConventions.RegisterDefaultConventions(
                (interfaceType, implementationType) => container.RegisterSingle(interfaceType, implementationType),
                new Assembly[] { siteMapProviderAssembly },
                allAssemblies,
                excludeTypes,
                string.Empty);

            // Multiple implementations of strategy based extension points (and not decorated with [ExcludeFromAutoRegistrationAttribute]).
            CommonConventions.RegisterAllImplementationsOfInterfaceSingle(
                (interfaceType, implementationTypes) => container.RegisterAll(interfaceType, implementationTypes),
                multipleImplementationTypes,
                allAssemblies,
                excludeTypes,
                string.Empty);

            container.Register<XmlSiteMapController>();

            // Visibility Providers
            container.RegisterSingle<ISiteMapNodeVisibilityProviderStrategy>(() =>
                new SiteMapNodeVisibilityProviderStrategy(
                    container.GetAllInstances<ISiteMapNodeVisibilityProvider>().ToArray(), string.Empty));

            // Pass in the global controllerBuilder reference
            container.RegisterSingle<ControllerBuilder>(() => ControllerBuilder.Current);

            container.RegisterSingle<IControllerTypeResolverFactory>(() =>
                new ControllerTypeResolverFactory(
                    new string[0],
                    container.GetInstance<IControllerBuilder>(),
                    container.GetInstance<IBuildManager>()));

            // Configure Security
            container.RegisterAll<IAclModule>(typeof(AuthorizeAttributeAclModule), typeof(XmlRolesAclModule));
            container.RegisterSingle<IAclModule>(() => new CompositeAclModule(container.GetAllInstances<IAclModule>().ToArray()));

            // Setup cache
            #if NET35
            container.RegisterSingleOpenGeneric(typeof(ICacheProvider<>), typeof(AspNetCacheProvider<>));
            container.RegisterSingle<ICacheDependency>(() => new AspNetFileCacheDependency(absoluteFileName));
            #else
            container.RegisterSingle<System.Runtime.Caching.ObjectCache>(() => System.Runtime.Caching.MemoryCache.Default);
            container.RegisterSingleOpenGeneric(typeof(ICacheProvider<>), typeof(RuntimeCacheProvider<>));
            container.RegisterSingle<ICacheDependency>(() => new RuntimeFileCacheDependency(absoluteFileName));
            #endif
            container.RegisterSingle<ICacheDetails>(() => new CacheDetails(absoluteCacheExpiration, TimeSpan.MinValue, container.GetInstance<ICacheDependency>()));

            // Configure the visitors
            container.RegisterSingle<ISiteMapNodeVisitor, UrlResolvingSiteMapNodeVisitor>();

            // Prepare for the sitemap node providers
            container.RegisterSingle<IReservedAttributeNameProvider>(() => new ReservedAttributeNameProvider(new string[0]));
            container.RegisterSingle<IXmlSource>(() => new FileXmlSource(absoluteFileName));

            // Register the sitemap node providers
            container.RegisterSingle<XmlSiteMapNodeProvider>(() => container.GetInstance<XmlSiteMapNodeProviderFactory>()
                .Create(container.GetInstance<IXmlSource>()));
            container.RegisterSingle<ReflectionSiteMapNodeProvider>(() => container.GetInstance<ReflectionSiteMapNodeProviderFactory>()
                .Create(includeAssembliesForScan));

            // Register the sitemap builders
            container.RegisterSingle<ISiteMapBuilder>(() => container.GetInstance<SiteMapBuilderFactory>()
                .Create(new CompositeSiteMapNodeProvider(container.GetInstance<XmlSiteMapNodeProvider>(), container.GetInstance<ReflectionSiteMapNodeProvider>())));

            container.RegisterAll<ISiteMapBuilderSet>(
                ResolveISiteMapBuilderSets(container, securityTrimmingEnabled, enableLocalization, visibilityAffectsDescendants, useTitleIfDescriptionNotProvided));
            container.RegisterSingle<ISiteMapBuilderSetStrategy>(() => new SiteMapBuilderSetStrategy(container.GetAllInstances<ISiteMapBuilderSet>().ToArray()));
        }
 public void RegisterServices(Container container)
 {
     container.RegisterAll<IModelBinder>(typeof(TaggableModelModelBinder));
 }
        public RegisterAllNonGeneric()
        {
            var container = new Container();

            container.RegisterAll(typeof(ICommon), new[] { typeof(CommonImpl1), typeof(CommonImpl2) });
        }
        public RegisterAllGeneric()
        {
            var container = new Container();

            container.RegisterAll<ICommon>(typeof(CommonImpl1), typeof(CommonImpl2));
        }
Exemple #15
0
        /// <summary>
        /// Register type mappings with container by configuration.
        /// </summary>
        /// <returns>The <see cref="IContainerProvider" /> object that this method was called on.</returns>
        public override IContainerProvider RegisterByConfiguration()
        {
            IoCSection section = ConfigurationManager.GetSection("ioc") as IoCSection; //<IoCSection>

            if (section == null)
            {
                throw new InvalidOperationException("Could not find IoC configuration section in Web.config");
            }

            var registerAllTypes = new Dictionary <Type, List <Type> >();

            foreach (IoCType typ in section.Types)
            {
                Type interfaceType = BuildManagerWrapper.Current.ResolveType(typ.Type);
                Type concreteType  = BuildManagerWrapper.Current.ResolveType(typ.MapTo);

                LifetimeType lifetimeType  = LifetimeType.Default;
                Lifestyle    lifestyleType = Lifestyle.Transient;

                switch (typ.Lifetime)
                {
                case "singleton":
                    lifetimeType  = LifetimeType.Singleton;
                    lifestyleType = Lifestyle.Singleton;
                    break;

                case "transient":
                    lifetimeType  = LifetimeType.Transient;
                    lifestyleType = Lifestyle.Transient;
                    break;
                }

                if (typ.RegisterAll == "true")
                {
                    if (!registerAllTypes.ContainsKey(interfaceType))
                    {
                        registerAllTypes.Add(interfaceType, new List <Type>()
                        {
                            concreteType
                        });
                    }
                    else
                    {
                        registerAllTypes[interfaceType].Add(concreteType);
                    }
                }
                else
                {
                    RegisterType(interfaceType, concreteType, lifetimeType);
                }
            }
            if (registerAllTypes.Count > 0)
            {
                foreach (KeyValuePair <Type, List <Type> > item in registerAllTypes)
                {
                    //if (item.Key == typeof (IController))
                    //{
                    //    foreach (var controller in item.Value)
                    //    {
                    //        RegisterType(controller, controller, LifetimeType.Transient);
                    //    }
                    //}
                    //else
                    //{
                    container.RegisterAll(item.Key, item.Value);
                    //}
                }
            }
            //container.RegisterMvcControllers(BuildManagerWrapper.Current.Assemblies.ToArray());
            return(this);
        }
Exemple #16
0
        private static Container CreateContainer()
        {
            var container = new Container();

            container.RegisterSingle<IMessageProcessOverseer, MessageProcessOverseer>();
            container.RegisterSingle<IVariableHandler, VariableHandler>();
#if DEBUG
            container
                .RegisterSingle<IDataStoreManager, InMemoryDataStoreManager>();
#else
            container
                .RegisterSingle<IDataStoreManager, SqliteDataStoreManager>();
#endif

            // Register all the IModules in the currently loaded assemblies
            var execPath = Assembly.GetExecutingAssembly().CodeBase;
            var assemblyPath = Environment.CurrentDirectory;

            LoadAssembliesFromPath(assemblyPath);

            var moduleTypes = AppDomain.CurrentDomain.GetAssemblies()
                                       .SelectMany(a => a.GetTypes())
                                       .Where(
                                           t =>
                                           typeof(IModule).IsAssignableFrom(t) &&
                                           t != typeof(IModule) && !t.IsAbstract)
                                       .ToList();

            foreach (var moduleType in moduleTypes)
            {
                container.RegisterSingle(moduleType, moduleType);
            }
            container.RegisterAll<IModule>(moduleTypes);

            return container;
        }