The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SubdomainRouteExtension.cs 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using System.Web.Mvc;
  2. using System.Web.Routing;
  3. namespace Teknik
  4. {
  5. public static class SubdomainRouteExtension
  6. {
  7. public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, string subDomain, string url, object defaults)
  8. {
  9. SubdomainRoute route = new SubdomainRoute(
  10. subDomain,
  11. url,
  12. new RouteValueDictionary(defaults),
  13. new MvcRouteHandler());
  14. routes.Add(name, route);
  15. return route;
  16. }
  17. public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, string subDomain, string url, object defaults, object constraints)
  18. {
  19. SubdomainRoute route = new SubdomainRoute(
  20. subDomain,
  21. url,
  22. new RouteValueDictionary(defaults),
  23. new RouteValueDictionary(constraints),
  24. new MvcRouteHandler());
  25. routes.Add(name, route);
  26. return route;
  27. }
  28. public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, string subDomain, string url, object defaults, string[] namespaces)
  29. {
  30. SubdomainRoute route = new SubdomainRoute(
  31. subDomain,
  32. url,
  33. new RouteValueDictionary(defaults),
  34. new RouteValueDictionary(namespaces),
  35. new MvcRouteHandler());
  36. routes.Add(name, route);
  37. return route;
  38. }
  39. public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, string subDomain, string url, object defaults)
  40. {
  41. SubdomainRoute route = new SubdomainRoute(
  42. subDomain,
  43. url,
  44. new RouteValueDictionary(defaults),
  45. new RouteValueDictionary(new {}),
  46. new RouteValueDictionary(new {Area = context.AreaName}),
  47. new MvcRouteHandler());
  48. context.Routes.Add(name, route);
  49. return route;
  50. }
  51. public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, string subDomain, string url, object defaults, object constraints)
  52. {
  53. SubdomainRoute route = new SubdomainRoute(
  54. subDomain,
  55. url,
  56. new RouteValueDictionary(defaults),
  57. new RouteValueDictionary(constraints),
  58. new RouteValueDictionary(new {Area = context.AreaName}),
  59. new MvcRouteHandler());
  60. context.Routes.Add(name, route);
  61. return route;
  62. }
  63. public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, string subDomain, string url, object defaults, string[] namespaces)
  64. {
  65. SubdomainRoute route = new SubdomainRoute(
  66. subDomain,
  67. url,
  68. new RouteValueDictionary(defaults),
  69. new RouteValueDictionary(new {}),
  70. new RouteValueDictionary(new { Area = context.AreaName, Namespaces = namespaces }),
  71. new MvcRouteHandler());
  72. context.Routes.Add(name, route);
  73. return route;
  74. }
  75. public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, string subDomain, string url, string area, object defaults)
  76. {
  77. SubdomainRoute route = new SubdomainRoute(
  78. subDomain,
  79. url,
  80. new RouteValueDictionary(defaults),
  81. new RouteValueDictionary(new { }),
  82. new RouteValueDictionary(new { Area = area }),
  83. new MvcRouteHandler());
  84. context.Routes.Add(name, route);
  85. return route;
  86. }
  87. public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, string subDomain, string url, string area, object defaults, object constraints)
  88. {
  89. SubdomainRoute route = new SubdomainRoute(
  90. subDomain,
  91. url,
  92. new RouteValueDictionary(defaults),
  93. new RouteValueDictionary(constraints),
  94. new RouteValueDictionary(new { Area = area }),
  95. new MvcRouteHandler());
  96. context.Routes.Add(name, route);
  97. return route;
  98. }
  99. public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, string subDomain, string url, string area, object defaults, string[] namespaces)
  100. {
  101. SubdomainRoute route = new SubdomainRoute(
  102. subDomain,
  103. url,
  104. new RouteValueDictionary(defaults),
  105. new RouteValueDictionary(new { }),
  106. new RouteValueDictionary(new { Area = area, Namespaces = namespaces }),
  107. new MvcRouteHandler());
  108. context.Routes.Add(name, route);
  109. return route;
  110. }
  111. }
  112. }