Exemple #1
0
        private static int test2(string cm)
        {
            string[] cc = cm.Split('.');
            Type     t;

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

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

            MethodInfo m = MReflect.GetMethod(t, "test");

            object[] para = new object[] {};
            int      rlt  = Convert.ToInt32(m.Invoke(o, para));

            return(rlt);
        }
Exemple #2
0
        private static int Test1(string ns, string cls, string mn)
        {
            Type t = MReflect.GetClsType(ns, cls);

            object o = MReflect.GenInstance(t);

            MethodInfo m = MReflect.GetMethod(t, mn);

            object[] para = {};
            m.Invoke(o, para);
            return(0);
        }
Exemple #3
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);
        }
Exemple #4
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);
            }
        }