Beispiel #1
0
 /// <summary>
 /// Método acionado no pré-processamento da rota.
 /// </summary>
 /// <param name="route"></param>
 /// <param name="request">Dados que estão sendo requisitados.</param>
 /// <returns></returns>
 protected virtual RouteActionResponse OnPreLoad(RouteInfo route, RouteActionRequest request)
 {
     return(new RouteActionResponse());
 }
Beispiel #2
0
 /// <summary>
 /// Método acionado quando a rota for carregada.
 /// </summary>
 /// <param name="route"></param>
 protected virtual void OnLoad(RouteInfo route)
 {
 }
Beispiel #3
0
 /// <summary>
 /// Método acionado quando a rota é inicialmente requisitada.
 /// </summary>
 /// <param name="route"></param>
 /// <param name="request"></param>
 /// <returns></returns>
 protected virtual RouteActionBeginResponse OnBeginRequest(RouteInfo route, RouteActionBeginRequest request)
 {
     return(new RouteActionBeginResponse());
 }
Beispiel #4
0
 /// <summary>
 /// Método acionado para o carregamento da rota.
 /// </summary>
 /// <param name="route"></param>
 internal void Load(RouteInfo route)
 {
     OnLoad(route);
 }
Beispiel #5
0
 /// <summary>
 /// Método acionado para o pré-carregamento da rota.
 /// </summary>
 /// <param name="route"></param>
 /// <returns></returns>
 internal RouteActionResponse PreLoad(RouteInfo route, RouteActionRequest request)
 {
     return(OnPreLoad(route, request));
 }
Beispiel #6
0
 /// <summary>
 /// Método acionado quando a rota é inicialmente requisitada.
 /// </summary>
 /// <param name="route"></param>
 /// <param name="request"></param>
 /// <returns></returns>
 internal RouteActionBeginResponse BeginRequest(RouteInfo route, RouteActionBeginRequest request)
 {
     return(OnBeginRequest(route, request));
 }
Beispiel #7
0
        public static void AddRouteInfo(string name, string location, string destinationPage, string path, string compiled, string actionName, string isDirectory, string isSecurePage, string forceNoSecurePage)
        {
            if (string.IsNullOrEmpty(path))
            {
                path = "*";
            }
            else
            {
                path = path.Replace(".", "").Replace(" ", "");
            }
            bool isCompiled = true;

            if (!bool.TryParse(compiled, out isCompiled))
            {
                isCompiled = true;
            }
            bool isDirectory1 = false;

            if (!bool.TryParse(isDirectory, out isDirectory1))
            {
                isDirectory1 = false;
            }
            bool isSecurePage1 = false;

            if (!bool.TryParse(isSecurePage, out isSecurePage1))
            {
                isSecurePage1 = false;
            }
            bool forceNoSecurePage1 = false;

            if (!bool.TryParse(forceNoSecurePage, out forceNoSecurePage1))
            {
                forceNoSecurePage1 = false;
            }
            RouteInfo info = new RouteInfo(name, location, destinationPage, path, isCompiled, actionName, isDirectory1, isSecurePage1, forceNoSecurePage1);
            string    loc  = "";

            if (!string.IsNullOrEmpty(info.Location) && info.Location[0] == '~')
            {
                loc = info.Location.Substring(1);
            }
            else
            {
                loc = info.Location;
            }
            if (!string.IsNullOrEmpty(loc) && loc[0] == '/')
            {
                loc = loc.Substring(1);
            }
            loc = loc.ToLower();
            var complexParts = Regex.Matches(loc, "{(?<part>[0-9]*?)}", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture);

            if (complexParts.Count > 0)
            {
                var complexRegex = loc;
                if (complexParts.Count == 1 && complexParts[0].Index == 0 && complexParts[0].Length == complexRegex.Length)
                {
                    complexRegex = "((?<complex" + complexParts[0].Groups["part"].Value + ">[\\s\\S]*?)/)|(?<complex" + complexParts[0].Groups["part"].Value + ">[\\s\\S]*)";
                }
                else
                {
                    foreach (Match i in complexParts)
                    {
                        if ((i.Index + i.Length == loc.Length))
                        {
                            complexRegex = complexRegex.Replace(i.Value, "(((?<complex" + i.Groups["part"].Value + ">[\\s\\S]*?)/)|(?<complex" + i.Groups["part"].Value + ">[\\s\\S]*))");
                        }
                        else
                        {
                            complexRegex = complexRegex.Replace(i.Value, "(?<complex" + i.Groups["part"].Value + ">[\\s\\S]*?)");
                        }
                    }
                }
                if (!_complexRoutesNavigate.ContainsKey(complexRegex))
                {
                    RouteInfoNavigate rNavAux = new RouteInfoNavigate(loc, null, info);
                    rNavAux.ComplexPartsCount = complexParts.Count;
                    rNavAux.ComplexRegex      = complexRegex;
                    _complexRoutesNavigate.Add(complexRegex, rNavAux);
                }
            }
            else if (!_routesNavigate.ContainsKey(loc))
            {
                RouteInfoNavigate rNavAux = new RouteInfoNavigate(loc, null, info);
                _routesNavigate.Add(loc, rNavAux);
            }
        }