Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 private int RunInstanceMethod(ModInfo mod, string method)
 {
     if (RModuled.ContainsKey(mod.modid))
     {
         Type     t    = RModuled[mod.modid].clsType;
         object   o    = RModuled[mod.modid].clsInst;
         object[] para = { };
         MReflect.RumMethordIgnoreRlt(t, method, o, para);
         return(0);
     }
     else
     {
         Logging.logger.Error("RunInstanceMethod failed ");
         return(-1);
     }
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
            }
        }