Exemplo n.º 1
0
        private void InstantiateModules()
        {
            foreach (LoadedModule loadedModule in Modules)
            {
                bool bHasModules = false;

                Assembly asm = loadedModule.Assembly;

                foreach (Type t in asm.GetTypes())
                {
                    if (typeof(Module).IsAssignableFrom(t) && !t.IsAbstract)
                    {
                        loadedModule.Module            = Activator.CreateInstance(t) as Module;
                        loadedModule.Module.ModulePath = loadedModule.Path;

                        if (loadedModule.Module == null)
                        {
                            Logger.Warn("Could not load Module {0} from assembly {1}", loadedModule.Module.GetType().Name, asm.FullName);
                            continue;
                        }


                        Logger.Info("Instantiated Module {0} from assembly {1}", loadedModule.Module.GetType().Name, asm.FullName);

                        CatchupModuleStartup(loadedModule);

                        bHasModules = true;
                    }
                }

                if (bHasModules)
                {
                    //Add this path to the filesystem
                    string Dir = Path.GetDirectoryName(loadedModule.Path);
                    FileSystem.AddFilesystemPath(Path.Combine(Dir, "Resources"));
                }
            }
        }