Esempio n. 1
0
 public RoleModulesController()
 {
     _roleModulesService = new RoleModulesService();
     _modulesService     = new ModuleServices();
 }
        // Protected methods

        private IImmutableSet <IModule> CreateModules()
        {
            var moduleBuilderServices = ModuleServices.BuildServiceProvider();

            return(moduleBuilderServices.GetServices <IModule>().ToImmutableHashSet());
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            bool createdNew;

            singleInstanceMutex = new Mutex(true, "FudgeMutex", out createdNew);

            if (!createdNew)
            {
                return;
            }

            GC.KeepAlive(singleInstanceMutex);

            if (!EventLog.SourceExists("Fudge Framework"))
            {
                EventLog.CreateEventSource(new EventSourceCreationData("Fudge Framework", "Fudge"));
            }

            EventLog.WriteEntry("Fudge Framework", "Framework started", EventLogEntryType.Information, 0, 0);

            moduleServices = new ModuleServices();

            FileSystemWatcher moduleWatcher = new FileSystemWatcher(Framework.GetModuleDirectory(), "*.dll");

            moduleWatcher.EnableRaisingEvents   = true;
            moduleWatcher.Created              += new FileSystemEventHandler(moduleWatcher_Created);
            moduleWatcher.IncludeSubdirectories = false;

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            Console.WriteLine("[fx] Fudge Framework v{0} started", Assembly.GetExecutingAssembly().GetName().Version);
            Console.WriteLine("[fx] Module directory is {0}", Framework.GetModuleDirectory());
            Console.WriteLine("[fx] Clearing temp directory ({0})", Framework.GetTempDirectory());

            try {
                foreach (string directory in Directory.GetDirectories(Framework.GetTempDirectory()))
                {
                    Directory.Delete(directory, true);
                }

                foreach (string file in Directory.GetFiles(Framework.GetTempDirectory()))
                {
                    File.Delete(file);
                }
            }

            catch {
                Console.WriteLine("[fx] Could not clear temp directory");
            }

            foreach (string file in Directory.GetFiles(Framework.GetModuleDirectory()))
            {
                if (Path.GetExtension(file) == ".dll")
                {
                    LoadModule(file);
                }
            }

            if (moduleServices.Modules.Count == 0)
            {
                Console.WriteLine("[fx] No modules loaded! Framework will exit.");
            }
            else
            {
                foreach (IModule module in moduleServices.Modules)
                {
                    InitializeModule(module);
                }
            }
        }
 public ModuleBuilder Add(Type moduleType)
 {
     ModuleServices.TryAddEnumerable(ServiceDescriptor.Singleton(typeof(IModule), moduleType));
     return(this);
 }