Beispiel #1
0
        public G get_KodAdmin <T, G>(Expression <Func <T, G> > expression) where T : BaseService where G : class
        {
            var instance = Activator.CreateInstance <T>();



            string controllerName = ReflectionHelper.GetProperty(instance, "ControllerName").ToString();
            string actionName     = ((MethodCallExpression)expression.Body).Method.Name;

            var parameterList = instance.GetType().GetMethod(actionName).GetParameters().Select(c => c.Name).ToList();

            var attr = instance.GetType().GetMember(actionName).FirstOrDefault().GetCustomAttribute(typeof(HttpAction), true) as HttpAction;


            RouteMapDTO route = new RouteMapDTO
            {
                Name       = controllerName,
                Route      = $"{controllerName}/{actionName}",
                HttpMethod = attr.HttpMethod
            };

            _httpService.SetRoute(route);

            var objects = expression.GetParamsFromExpression();
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            for (int i = 0; i < parameterList.Count; i++)
            {
                dictionary.Add(parameterList[i], objects[i]);
            }

            return(_httpService.Send <G>(dictionary));
        }
Beispiel #2
0
        public void RunSet <T, G>(G g, Expression <Func <T, G> > expression) where T : BaseService where G : class
        {
            object gg       = g;
            var    instance = Activator.CreateInstance <T>();

            if (__RunningLocal)
            {
                var action = expression.Compile();

                gg = action(instance);
            }
            else
            {
                string controllerName = SIS.Service.Extensions.ReflectionHelper.GetProperty(instance, "ControllerName").ToString();
                string actionName     = ((MethodCallExpression)expression.Body).Method.Name;

                var parameterList = instance.GetType().GetMethod(actionName).GetParameters().Select(c => c.Name).ToList();

                var attr = instance.GetType().GetMember(actionName).FirstOrDefault().GetCustomAttribute(typeof(HttpAction), true) as HttpAction;


                RouteMapDTO route = new RouteMapDTO
                {
                    Name       = controllerName,
                    Route      = $"{controllerName}/{actionName}",
                    HttpMethod = attr.HttpMethod
                };
                _httpService.SetRoute(route);

                var objects = expression.GetParamsFromExpression();
                Dictionary <string, object> dictionary = new Dictionary <string, object>();
                for (int i = 0; i < parameterList.Count; i++)
                {
                    dictionary.Add(parameterList[i], objects[i]);
                }

                gg = _httpService.Send <G>(dictionary);
            }
        }
Beispiel #3
0
 public void SetRoute(RouteMapDTO route)
 {
     routeMapDto = route;
 }