Esempio n. 1
0
 void UpdateDelegate()
 {
     if (ControllerType != null && !String.IsNullOrEmpty(ActionName))
     {
         actionMethodInfo = ControllerType.GetMethod(ActionName);
         actionInvoker    = Helper.CreateMethodInvokerDelegate(actionMethodInfo);
     }
 }
Esempio n. 2
0
        void UpdateDelegate()
        {
            if (!String.IsNullOrEmpty(Controller))
            {
                //var a1 = AppDomain.CurrentDomain.GetReferencingAssemblies("TestController");
            }

            if (ControllerType != null && !String.IsNullOrEmpty(Action))
            {
                actionMethodInfo = ControllerType.GetMethod(Action);
                actionInvoker    = Helper.CreateMethodInvokerDelegate(actionMethodInfo);
            }
        }
Esempio n. 3
0
            public ActionMethodInfo GetActionMethod(BindingFlags actionFlags)
            {
                MethodInfo actionMethod;

                actionMethod = ControllerType.GetMethod(ActionName, actionFlags, null, Type.EmptyTypes, null);
                if (actionMethod == null)
                {
                    //尝试获取使用请求类型显式命名的操作方法
                    actionMethod = ControllerType.GetMethod(
                        string.Format("{0}{1}", ActionName, HttpMethod), actionFlags, null, Type.EmptyTypes, null);
                }
                if (actionMethod == null)
                {
                    return(null);
                }
                return(new ActionMethodInfo(actionMethod, ActionName));
            }
Esempio n. 4
0
        public virtual void Transfer()
        {
            Services.Controller.CancelView();
            Render();

            var types     = new List <Type>();
            var arguments = new List <object>();

            foreach (var argument in Arguments)
            {
                arguments.Add(argument.Value);
                types.Add(argument.Type);
            }

            var method = ControllerType.GetMethod(ActionName, types.ToArray());

            if (method == null)
            {
                throw new ArgumentException("Transfer failed, no method named: " + ActionName);
            }

            method.Invoke(Services.Controller, arguments.ToArray());
        }
Esempio n. 5
0
        public static void GetContactMustBeHttpGet()
        {
            var httpGetAttribute = ControllerType.GetMethod(nameof(GetContactController.GetContact))?.GetCustomAttribute <HttpGetAttribute>();

            httpGetAttribute.MustNotBeNull().Template.Should().Be("{id}");
        }
 public static void UpdateContactMustBeHttpPut() =>
 ControllerType.GetMethod(nameof(UpdateContactController.UpdateContact)).Should().BeDecoratedWith <HttpPutAttribute>();
 public static void CreateNewContactMustBeHttpPost() =>
 ControllerType.GetMethod(nameof(NewContactController.CreateNewContact)).Should().BeDecoratedWith <HttpPostAttribute>();
Esempio n. 8
0
 public static void GetContactsMustBeDecoratedWithHttpGetAttribute() =>
 ControllerType.GetMethod(nameof(GetContactsController.GetContacts)).Should().BeDecoratedWith <HttpGetAttribute>();