예제 #1
0
        private static void LoadControllerClasses()
        {
            _controllerClasses = new Dictionary <string, ControllerClass>(StringComparer.Ordinal);

            List <Type> controllerTypes = new List <Type>();

            foreach (Assembly assembly in _registeredAssemblies)
            {
                controllerTypes.AddRange(Util.FindCompatibleTypes(assembly, typeof(Controller)));
            }

            foreach (Type type in controllerTypes)
            {
                string baseAssemblyNamespace = type.Assembly.FullName.Split(',')[0] + ".PageControllers";

                if (type.FullName.IndexOf(baseAssemblyNamespace) != -1)
                {
                    string url = type.FullName.Substring(baseAssemblyNamespace.Length + 1).Replace('.', '/');

                    ControllerClass controllerClass = new ControllerClass(type, url.ToLower());

                    _controllerClasses.Add(controllerClass.Name, controllerClass);
                }
            }
        }
예제 #2
0
        internal static ControllerClass GetControllerClass(string url)
        {
            ControllerClass controllerClass = null;

            _controllerClasses.TryGetValue(url, out controllerClass);

            return(controllerClass);
        }
예제 #3
0
        internal void Init(ControllerClass controllerClass)
        {
            if (_viewName == null)
            {
                _viewName = controllerClass.Name;
            }

            _name = controllerClass.Name;
        }
예제 #4
0
        internal static Controller RunNoAccessAction(ControllerAction controllerAction)
        {
            WebAppContext.Response.DisableCaching();

            ControllerClass controllerClass = controllerAction.ControllerClass;

            using (Controller controller = controllerClass.CreateController())
            {
                controller.NoAccess(controllerAction);
                return(controller);
            }
        }
예제 #5
0
        internal static ControllerAction GetControllerAction(string relativePath, string pathInfo)
        {
            if (string.IsNullOrEmpty(pathInfo))
            {
                pathInfo = "Run";
            }
            else
            {
                pathInfo = pathInfo.Substring(1);
            }

            ControllerClass controllerClass = WebAppConfig.GetControllerClass(UrlHelper.GetUrlPathWithoutExtension(relativePath).ToLower());

            return(controllerClass == null ? null : new ControllerAction(controllerClass, pathInfo));
        }
예제 #6
0
        internal static Controller RunControllerAction(ControllerAction controllerAction)
        {
            WebAppContext.Response.DisableCaching();

            ControllerClass controllerClass = controllerAction.ControllerClass;

            using (Controller controller = controllerClass.CreateController())
            {
                if (controllerClass.Run(controller, controllerAction.Method))
                {
                    return(controller);
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #7
0
 public ControllerAction(ControllerClass controllerClass, string method)
 {
     _controllerClass = controllerClass;
     _method = method;
 }
예제 #8
0
파일: Controller.cs 프로젝트: yslib/minimvc
        internal void Init(ControllerClass controllerClass)
        {
            if (_viewName == null)
                _viewName = controllerClass.Name;

            _name = controllerClass.Name;
        }
예제 #9
0
 public ControllerAction(ControllerClass controllerClass, string method)
 {
     _controllerClass = controllerClass;
     _method          = method;
 }
예제 #10
0
        private static void LoadControllerClasses()
        {
            _controllerClasses = new Dictionary<string, ControllerClass>(StringComparer.Ordinal);

            List<Type> controllerTypes = new List<Type>();

            foreach (Assembly assembly in _registeredAssemblies)
            {
                controllerTypes.AddRange(Util.FindCompatibleTypes(assembly, typeof(Controller)));
            }

            foreach (Type type in controllerTypes)
            {
                string baseAssemblyNamespace = type.Assembly.FullName.Split(',')[0] + ".PageControllers";

                if (type.FullName.IndexOf(baseAssemblyNamespace) != -1)
                {
                    string url = type.FullName.Substring(baseAssemblyNamespace.Length + 1).Replace('.', '/');

                    ControllerClass controllerClass = new ControllerClass(type, url.ToLower());

                    _controllerClasses.Add(controllerClass.Name, controllerClass);
                }
            }
        }