예제 #1
0
 internal static void DiscoverCommandFactories(ModuleAssembly In, CommandParser AddTo)
 {
     foreach (var type in In.Assembly.GetTypes())
     {
         if (type.FullName.StartsWith(In.Info.BaseNameSpace) && type.IsSubclassOf(typeof(CommandFactory)))
         {
             CommandFactory.CreateCommandFactory(type).Create(AddTo);
         }
     }
 }
예제 #2
0
파일: Startup.cs 프로젝트: SinaC/RMUD
        /// <summary>
        /// Integrate a module into the running game by calling every static AtStartup method found on any type
        /// in the module's base namespace.
        /// </summary>
        /// <param name="Module"></param>
        private static void IntegrateModule(ModuleAssembly Module)
        {
            if (Module == null)
            {
                throw new InvalidOperationException("Tried to load null module");
            }
            if (Module.Assembly == null)
            {
                throw new InvalidOperationException("Tried to load invalid module assembly - " + Module.FileName);
            }
            if (Module.Info == null)
            {
                throw new InvalidOperationException("Tried to load invalid module assembly - " + Module.FileName);
            }

            foreach (var type in Module.Assembly.GetTypes())
            {
                if (type.FullName.StartsWith(Module.Info.BaseNameSpace))
                {
                    foreach (var method in type.GetMethods())
                    {
                        if (method.IsStatic && method.Name == "AtStartup")
                        {
                            try
                            {
                                method.Invoke(null, new Object[] { GlobalRules });
                            }
                            catch (Exception e)
                            {
                                LogWarning("Error while loading module " + Module.FileName + " : " + e.Message);
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
파일: Startup.cs 프로젝트: Reddit-Mud/RMUD
        /// <summary>
        /// Integrate a module into the running game by calling every static AtStartup method found on any type
        /// in the module's base namespace.
        /// </summary>
        /// <param name="Module"></param>
        private static void IntegrateModule(ModuleAssembly Module)
        {
            if (Module == null) throw new InvalidOperationException("Tried to load null module");
            if (Module.Assembly == null) throw new InvalidOperationException("Tried to load invalid module assembly - " + Module.FileName);
            if (Module.Info == null) throw new InvalidOperationException("Tried to load invalid module assembly - " + Module.FileName);

            foreach (var type in Module.Assembly.GetTypes())
                if (type.FullName.StartsWith(Module.Info.BaseNameSpace))
                    foreach (var method in type.GetMethods())
                        if (method.IsStatic && method.Name == "AtStartup")
                            try
                            {
                                method.Invoke(null, new Object[] { GlobalRules });
                            }
                            catch (Exception e)
                            {
                                LogWarning("Error while loading module " + Module.FileName + " : " + e.Message);
                            }
        }
예제 #4
0
 internal static void DiscoverCommandFactories(ModuleAssembly In, CommandParser AddTo)
 {
     foreach (var type in In.Assembly.GetTypes())
         if (type.FullName.StartsWith(In.Info.BaseNameSpace) && type.IsSubclassOf(typeof(CommandFactory)))
             CommandFactory.CreateCommandFactory(type).Create(AddTo);
 }