コード例 #1
0
        private int InitClass(ModInfo mod)
        {
            string[] cc = mod.cls.Split('.');
            Type     t;

            t = MReflect.GetClsType(cc[0], mod.cls);
            if (t == null)
            {
                Logging.logger.Error("Get Type failed " + mod.modname + " " + mod.cls);
                return(-1);
            }
            object o = MReflect.GenInstance(t);

            if (o == null)
            {
                Logging.logger.Error("Get Type failed " + mod.modname + " " + mod.cls);
                return(-1);
            }

            object[] para = new object[] { mod };
            //MReflect.RumMethordIgnoreRlt(t, "SetModBaseInfo", o, para);
            MethodInfo m = MReflect.GetMethod(t, "SetModBaseInfo");

            Convert.ToInt32(m.Invoke(o, para));
            //return rlt;

            if (RModuled.ContainsKey(mod.modid))
            {
                Logging.logger.Warn("The class is running " + mod.cls + " " + mod.modname + " " + mod.modid.ToString());
                return(0);
            }
            else
            {
                RunMod rm = new RunMod();
                rm.clsInst = o;
                rm.clsType = t;
                rm.modid   = mod.modid;
                rm.modname = mod.modname;
                RModuled.Add(mod.modid, rm);
            }
            return(0);
        }
コード例 #2
0
        public int RunModInstanceMethord(string modname, string methodname, object[] para)
        {
            int modid;
            int rlt = GetModIDFromName(modname, out modid);

            if (rlt != 0)
            {
                return(-1);
            }

            if (methodname == null)
            {
                return(-1);
            }

            if (RModuled.ContainsKey(modid))
            {
                RunMod rm = RModuled[modid];

                MethodInfo m = MReflect.GetMethod(rm.clsType, methodname);

                try
                {
                    m.Invoke(rm.clsInst, para);
                }
                catch (Exception err)
                {
                    Logging.logger.Error(modname + " " + methodname + " RunModInstanceMethord failed " + err.Message);
                    return(-1);
                }

                return(0);
            }
            else
            {
                return(-1);
            }
        }