示例#1
0
 public bool LoadMethod(string fullClassName, string methodName)
 {
     try
     {
         MethodLoader methodLoader = this.FindMethod(fullClassName, methodName);
         if (null != methodLoader)
         {
             return(true);
         }
         methodLoader    = new MethodLoader();
         methodLoader.tp = this.assembly.GetType(fullClassName);
         if (null == methodLoader.tp)
         {
             return(false);
         }
         methodLoader.method = methodLoader.tp.GetMethod(methodName);
         if (null == methodLoader.method)
         {
             return(false);
         }
         methodLoader.obj = Activator.CreateInstance(methodLoader.tp);
         if (null == methodLoader.obj)
         {
             return(false);
         }
         this.AddMethod(fullClassName, methodName, methodLoader);
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Error, string.Format("AssemblyLoader::LoadMethod Error, fullClassName={0}, methodName={1}", fullClassName, methodName), ex, false);
         return(false);
     }
     return(true);
 }
示例#2
0
 public void AddMethod(string fullClassName, string methodName, MethodLoader methodLoader)
 {
     try
     {
         string strKey = string.Format("{0}.{1}", fullClassName, methodName);
         this.dictMethodLoader.Add(strKey, methodLoader);
     }
     catch
     {
         LogManager.WriteLog(LogTypes.Error, string.Format("AssemblyLoader::AddMethod Error, fullClassName={0} methodName={1}", fullClassName, methodName), null, true);
     }
 }
示例#3
0
        public MethodLoader FindMethod(string fullClassName, string methodName)
        {
            MethodLoader methodLoader = null;
            string       strKey       = string.Format("{0}.{1}", fullClassName, methodName);
            MethodLoader result;

            if (this.dictMethodLoader.TryGetValue(strKey, out methodLoader))
            {
                result = methodLoader;
            }
            else
            {
                result = null;
            }
            return(result);
        }
示例#4
0
        public object Invoke(string fullClassName, string methodName, object[] args)
        {
            MethodLoader methodLoader = null;
            string       strKey       = string.Format("{0}.{1}", fullClassName, methodName);
            object       result;

            if (!this.dictMethodLoader.TryGetValue(strKey, out methodLoader))
            {
                result = null;
            }
            else
            {
                result = methodLoader.method.Invoke(methodLoader.obj, args);
            }
            return(result);
        }