コード例 #1
0
        public ActionResult <Object> CallMethod([FromBody] TypeLoadEntity entity)
        {
            typeLoadValidator.validate(entity);
            var resp = context.CallMethod(entity);

            return(resp);
        }
コード例 #2
0
        private Assembly getDll(TypeLoadEntity entity)
        {
            Assembly dll;

            if (!dlls.TryGetValue(entity.DllName, out dll))
            {
                throw new Common.Exceptions.DllNotFoundException(string.Format("Dll {0} not found", entity.DllName));
            }
            return(dll);
        }
コード例 #3
0
        private static Type getClass(TypeLoadEntity entity, Assembly dll)
        {
            Type classType = dll.GetType(entity.FullClassName);

            if (classType == null)
            {
                throw new ClassNotFoundException(entity.FullClassName);
            }
            return(classType);
        }
コード例 #4
0
        private object TryToCallMethod(TypeLoadEntity entity, object obj, Type type)
        {
            var           method = GetMethod(entity.MethodArgs, type, entity.MethodName);
            List <object> args   = new List <object>();

            foreach (var item in entity.MethodArgs)
            {
                args.Add(TryToInit(item, false));
            }
            return(method.Invoke(obj, args.ToArray()));
        }
コード例 #5
0
        public object CallMethod(TypeLoadEntity entity)
        {
            var obj = TryToInit(entity, true);

            return(TryToCallMethod(entity, obj, obj.GetType()));
        }