예제 #1
0
        public IOxiteModule Load(Module module)
        {
            if (module == null)
            {
                return(null);
            }

            Type type = Type.GetType(module.Type);

            if (type == null)
            {
                foreach (var assembly in BuildManager.CodeAssemblies)
                {
                    type = ((Assembly)assembly).GetExportedTypes().FirstOrDefault(t => t.FullName == module.Type);

                    if (type != null)
                    {
                        break;
                    }
                }
            }

            if (type == null)
            {
                throw new TypeLoadException(string.Format("Could not load type '{0}'.", module.Type));
            }

            IOxiteModule moduleInstance = container.Resolve(type) as IOxiteModule;

            modules.Add(moduleInstance);

            return(moduleInstance);
        }
예제 #2
0
        public IOxiteModule Load(OxiteConfigurationSection config, OxiteModuleConfigurationElement module)
        {
            if (module == null || !module.Enabled)
            {
                return(null);
            }

            foreach (OxiteDataProviderConfigurationElement dataProvider in config.Providers)
            {
                if (dataProvider.Name == module.DataProvider)
                {
                    Type dataProviderType = Type.GetType(dataProvider.Type);

                    if (dataProviderType == null)
                    {
                        throw new TypeLoadException(string.Format("Could not load type '{0}'.", dataProvider.Type));
                    }

                    IOxiteDataProvider dataProviderInstance = container.Resolve(dataProviderType) as IOxiteDataProvider;

                    if (dataProviderInstance != null)
                    {
                        dataProviderInstance.ConfigureProvider(config, dataProvider, container);
                    }

                    break;
                }
            }

            Type type = Type.GetType(module.Type);

            if (type == null)
            {
                foreach (var assembly in BuildManager.CodeAssemblies)
                {
                    type = ((Assembly)assembly).GetExportedTypes().FirstOrDefault(t => t.FullName == module.Type);

                    if (type != null)
                    {
                        break;
                    }
                }
            }

            if (type == null)
            {
                throw new TypeLoadException(string.Format("Could not load type '{0}'.", module.Type));
            }

            IOxiteModule moduleInstance = container.Resolve(type) as IOxiteModule;

            modules.Add(moduleInstance);

            return(moduleInstance);
        }
예제 #3
0
        public void Execute(IDictionary <string, object> state)
        {
            IModulesLoaded        modulesLoaded  = container.Resolve <IModulesLoaded>();
            RouteCollection       routes         = container.Resolve <RouteCollection>();
            IFilterRegistry       filterRegistry = container.Resolve <FilterRegistry>();
            ModelBinderDictionary modelBinders   = container.Resolve <ModelBinderDictionary>();

            filterRegistry.Clear();

            modelBinders.Clear();

            //todo: (nheskew) get plugin routes registered on load in the right order instead of just clearing the routes before module init
            routes.Clear();

            foreach (Module module in container.Resolve <IModuleService>().GetModules())
            {
                IOxiteModule moduleInstance = modulesLoaded.Load(module);

                if (moduleInstance != null)
                {
                    moduleInstance.RegisterWithContainer();
                    moduleInstance.Initialize();
                    moduleInstance.RegisterFilters(filterRegistry);
                    moduleInstance.RegisterModelBinders(modelBinders);

                    container.RegisterInstance(modulesLoaded);
                }
            }

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.LoadFromModules(modulesLoaded);

            routes.LoadCatchAllFromModules(modulesLoaded);

            container.RegisterInstance(filterRegistry);

            ////TODO: (erikpo) Rename IOxiteModule to IOxiteBackgroundService
            //IModuleRegistry moduleRegistry = container.Resolve<ModuleRegistry>();

            //moduleRegistry.Clear();

            //container.Resolve<IRegisterModules>().RegisterModules(moduleRegistry);

            //foreach (IOxiteModule module in moduleRegistry.GetModules())
            //    module.Start();

            //container.RegisterInstance(moduleRegistry);
        }
예제 #4
0
        public void Execute(IDictionary <string, object> state)
        {
            OxiteConfigurationSection config         = container.Resolve <OxiteConfigurationSection>();
            IModulesLoaded            modulesLoaded  = this.container.Resolve <IModulesLoaded>();
            RouteCollection           routes         = this.container.Resolve <RouteCollection>();
            IFilterRegistry           filterRegistry = this.container.Resolve <FilterRegistry>();
            ModelBinderDictionary     modelBinders   = this.container.Resolve <ModelBinderDictionary>();

            filterRegistry.Clear();

            modelBinders.Clear();

            //todo: (nheskew) get plugin routes registered on load in the right order instead of just clearing the routes before module init
            routes.Clear();

            foreach (OxiteModuleConfigurationElement module in config.Modules)
            {
                IOxiteModule moduleInstance = modulesLoaded.Load(config, module);

                if (moduleInstance != null)
                {
                    moduleInstance.RegisterWithContainer();
                    moduleInstance.Initialize();
                    moduleInstance.RegisterFilters(filterRegistry);
                    moduleInstance.RegisterModelBinders(modelBinders);

                    this.container.RegisterInstance(modulesLoaded);
                }
            }

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.LoadFromModules(modulesLoaded);

            routes.LoadCatchAllFromModules(modulesLoaded);

            container.RegisterInstance(filterRegistry);
        }