コード例 #1
0
        internal string GetRouteValuesDescriptor()
        {
            lock ( _sync )
            {
                if (_routeValuesDescriptor != null)
                {
                    return(_routeValuesDescriptor);
                }

                List <string> list = new List <string>();

                foreach (var key in RouteKeys.OrderBy(k => k, StringComparer.OrdinalIgnoreCase))
                {
                    string value;

                    if (StaticRouteValues.TryGetValue(key, out value))
                    {
                        list.Add(string.Format("<\"{0}\",\"{1}\">", key.Replace("\"", "\\\""), value.Replace("\"", "\\\"")));
                    }

                    else
                    {
                        list.Add(string.Format("<\"{0}\",dynamic>", key.Replace("\"", "\\\"")));
                    }
                }

                return(_routeValuesDescriptor = string.Join(",", list.ToArray()));
            }
        }
コード例 #2
0
 public void EnsureAllRoutesAreRegisteredTest()
 {
     foreach (var routePathItem in TodoController.GetRoutePaths)
     {
         var key = RouteKeys.CreateActionKey(routePathItem.Value);
         Assert.True(_routeProvider.RouteMap.ContainsKey(key));
     }
 }
コード例 #3
0
    public static void CreateAndRegisterRoutes(IChromelyRouteProvider routeProvider, ChromelyController controller, IChromelyModelBinder routeParameterBinder, IChromelyDataTransferOptions dataTransferOptions)
    {
        if (routeProvider is null || controller is null)
        {
            return;
        }

        var methodInfos = controller.GetType().GetMethods()
                          .Where(m => m.GetCustomAttributes(typeof(ChromelyRouteAttribute), false).Length > 0)
                          .ToArray();

        foreach (var methodInfo in methodInfos)
        {
            var attribute = methodInfo.GetCustomAttribute <ChromelyRouteAttribute>();
            var key       = RouteKeys.CreateActionKey(controller.RoutePath, attribute?.Path ?? string.Empty);
            if (!routeProvider.RouteExists(key))
            {
                routeProvider.RegisterRoute(key, ControllerRoutesFactory.CreateDelegate(controller, methodInfo, routeParameterBinder, dataTransferOptions));
            }
        }
    }
コード例 #4
0
        protected RouteValueDictionary      CloneRouteDirectory(PageHandlerExecutingContext context)
        {
            var dictionaryData = new RouteValueDictionary();

            string[] RouteKeyNames = null;

            var IsRouteKey = !string.IsNullOrWhiteSpace(RouteKeys);

            if (IsRouteKey)
            {
                RouteKeyNames = RouteKeys.Split(",", StringSplitOptions.RemoveEmptyEntries);
            }

            var AnyRouteKey = RouteKeyNames != null && RouteKeyNames.Any();

            foreach (var item in context.HttpContext.Request.Query)
            {
                if (string.Equals(item.Key, "handler", StringComparison.OrdinalIgnoreCase) && !CopyRouteDataHandler)
                {
                    continue;
                }

                if (IsRouteKey)
                {
                    if (AnyRouteKey && RouteKeyNames.Contains(item.Key))
                    {
                        dictionaryData.Add(item.Key, item.Value);
                    }
                }
                else
                {
                    dictionaryData.Add(item.Key, item.Value);
                }
            }
            return(dictionaryData);
        }
コード例 #5
0
ファイル: Route.cs プロジェクト: mteletin/NXtel
 public Route(RouteKeys KeyCode, string Description)
     : base()
 {
     this.KeyCode     = (byte)KeyCode;
     this.Description = Description;
 }