Esempio n. 1
0
        public void GetRouteHandlerTest()
        {
            ReflectHelper reflectHelper = new ReflectHelper();
            reflectHelper.setGlobalNamespace("CourseServer.Controllers");
            reflectHelper.setInsecureReflect(true);
            RouteHandlerInfo handlerInfo = reflectHelper.GetRouteHandler("Advance.UserManagerController@AllUser");

            Assert.AreEqual(typeof(UserManagerController), handlerInfo.Handler);

            Assert.AreEqual(1, handlerInfo.ParamInfo.Length);

            //Assert.AreEqual("DoSomething", handlerInfo.Callback.Name);
        }
Esempio n. 2
0
        private static RouteInfo Parse(string route, string handler, 
            string args, bool cache)
        {
            if (TextUtils.isEmpty(route) || TextUtils.isEmpty(handler))
                return null;

            ReflectHelper reflectHelper = new ReflectHelper();
            // Set up the default namespace for the handle class
            reflectHelper.setGlobalNamespace( GlobalSettings.NAMESPACE );
            // Separate out the handle class and method
            RouteHandlerInfo routeHandler = reflectHelper.GetRouteHandler(handler);

            if (routeHandler == null)
                return null;

            string[] expectArgs = null;
            if (!TextUtils.isEmpty(args))
            {
                expectArgs = args.Split(',');
                List<string> argBuilder = new List<string>();
                // Clear up the arguments
                foreach (string arg in expectArgs)
                {
                    if (TextUtils.isEmpty(arg)) continue;

                    argBuilder.Add(arg.Trim());
                }
                // Rebuild the arguments
                expectArgs = argBuilder.Count == 0 ? null : argBuilder.ToArray();
            }

            return new RouteInfo(route, expectArgs, cache, routeHandler);
        }