Пример #1
0
 /// <summary>
 /// Método acionado quando a rota for carregada.
 /// </summary>
 internal void Load()
 {
     if (!string.IsNullOrEmpty(ActionName))
     {
         var action = RouteSettings.GetAction(ActionName);
         if (action != null)
         {
             action.Load(this);
         }
     }
 }
Пример #2
0
 /// <summary>
 /// Método acionado quando a rota está sendo pré-carregada.
 /// </summary>
 internal RouteActionResponse PreLoad(RouteActionRequest request)
 {
     if (!string.IsNullOrEmpty(ActionName))
     {
         var action = RouteSettings.GetAction(ActionName);
         if (action != null)
         {
             return(action.PreLoad(this, request));
         }
     }
     return(null);
 }
Пример #3
0
        /// <summary>
        /// Recupera e define a instacia para a rota com base no caminho virtual.
        /// </summary>
        /// <param name="virtualPath"></param>
        /// <returns></returns>
        public static LoadRouteResult GetItem(string virtualPath)
        {
            if (RouteSettings.LoadConfiguration() || _accessRoute == null)
            {
                _accessRoute = new int[RouteSettings.CacheMaximumItems];
                _routes      = new LoadRouteResult[RouteSettings.CacheMaximumItems];
            }
            int pos = -1;

            for (int i = 0; i < _routes.Length; i++)
            {
                if (pos < 0 && _routes[i] != null && _routes[i].VirtualPath == virtualPath)
                {
                    _accessRoute[i]++;
                    pos = i;
                }
                else
                {
                    if (_accessRoute[i] > int.MinValue)
                    {
                        _accessRoute[i]--;
                    }
                }
            }
            if (pos >= 0)
            {
                return(_routes[pos]);
            }
            pos = 0;
            for (int i = 1; i < _accessRoute.Length; i++)
            {
                if (_accessRoute[i] < _accessRoute[pos])
                {
                    pos = i;
                }
            }
            if (_routes[pos] != null)
            {
                GC.ReRegisterForFinalize(_routes[pos]);
            }
            _accessRoute[pos] = 10;
            _routes[pos]      = LoadRoute(virtualPath);
            return(_routes[pos]);
        }