Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 2
0
        internal static ControllerClass GetControllerClass(string url)
        {
            ControllerClass controllerClass = null;

            _controllerClasses.TryGetValue(url, out controllerClass);

            return(controllerClass);
        }
Exemplo n.º 3
0
        internal void Init(ControllerClass controllerClass)
        {
            if (_viewName == null)
            {
                _viewName = controllerClass.Name;
            }

            _name = controllerClass.Name;
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 7
0
 public ControllerAction(ControllerClass controllerClass, string method)
 {
     _controllerClass = controllerClass;
     _method = method;
 }
Exemplo n.º 8
0
        internal void Init(ControllerClass controllerClass)
        {
            if (_viewName == null)
                _viewName = controllerClass.Name;

            _name = controllerClass.Name;
        }
Exemplo n.º 9
0
 public ControllerAction(ControllerClass controllerClass, string method)
 {
     _controllerClass = controllerClass;
     _method          = method;
 }
Exemplo n.º 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);
                }
            }
        }