Permalink
Browse files

Merge pull request #769 from PaulAtkins/767-Mvc-AttributeRoutes-Fix

Added support for MVC attribute routes (fixes #767)
  • Loading branch information...
avanderhoorn committed Apr 23, 2014
2 parents 1efb061 + 4f016e0 commit ca463a971ff2df1f921ad31452d61bfd226a40be
Showing with 23,028 additions and 80 deletions.
  1. +12 −0 Glimpse.All.sln
  2. +257 −0 source/Glimpse.AspNet/AlternateType/Route.cs
  3. +3 −28 source/Glimpse.AspNet/AlternateType/RouteBase.cs
  4. +2 −0 source/Glimpse.AspNet/Glimpse.AspNet.csproj
  5. +41 −9 source/Glimpse.AspNet/Inspector/RoutesInspector.cs
  6. +39 −0 source/Glimpse.AspNet/Message/RouteDataMessage.cs
  7. +39 −14 source/Glimpse.AspNet/Tab/Routes.cs
  8. BIN source/Glimpse.Mvc5.MusicStore.Sample/App_Data/ASPNETDB_ReadOnly.mdf
  9. BIN source/Glimpse.Mvc5.MusicStore.Sample/App_Data/ASPNETDB_log_ReadOnly.ldf
  10. BIN source/Glimpse.Mvc5.MusicStore.Sample/App_Data/MvcMusicStore_ReadOnly.mdf
  11. BIN source/Glimpse.Mvc5.MusicStore.Sample/App_Data/MvcMusicStore_log_ReadOnly.ldf
  12. +39 −0 source/Glimpse.Mvc5.MusicStore.Sample/App_Start/AppConfig.cs
  13. +32 −0 source/Glimpse.Mvc5.MusicStore.Sample/App_Start/AuthConfig.cs
  14. +26 −0 source/Glimpse.Mvc5.MusicStore.Sample/App_Start/BundleConfig.cs
  15. +13 −0 source/Glimpse.Mvc5.MusicStore.Sample/App_Start/FilterConfig.cs
  16. +25 −0 source/Glimpse.Mvc5.MusicStore.Sample/App_Start/RouteConfig.cs
  17. +19 −0 source/Glimpse.Mvc5.MusicStore.Sample/App_Start/WebApiConfig.cs
  18. +928 −0 source/Glimpse.Mvc5.MusicStore.Sample/Content/Site.css
  19. +426 −0 source/Glimpse.Mvc5.MusicStore.Sample/Controllers/AccountController.cs
  20. +24 −0 source/Glimpse.Mvc5.MusicStore.Sample/Controllers/AttributeRoutingTestController.cs
  21. +85 −0 source/Glimpse.Mvc5.MusicStore.Sample/Controllers/CheckoutController.cs
  22. +35 −0 source/Glimpse.Mvc5.MusicStore.Sample/Controllers/FileUploadController.cs
  23. +82 −0 source/Glimpse.Mvc5.MusicStore.Sample/Controllers/HomeController.cs
  24. +95 −0 source/Glimpse.Mvc5.MusicStore.Sample/Controllers/ModelBindingTestsController.cs
  25. +107 −0 source/Glimpse.Mvc5.MusicStore.Sample/Controllers/ShoppingCartController.cs
  26. +60 −0 source/Glimpse.Mvc5.MusicStore.Sample/Controllers/StoreController.cs
  27. +127 −0 source/Glimpse.Mvc5.MusicStore.Sample/Controllers/StoreManagerController.cs
  28. +50 −0 source/Glimpse.Mvc5.MusicStore.Sample/Filters/InitializeSimpleMembershipAttribute.cs
  29. +367 −0 source/Glimpse.Mvc5.MusicStore.Sample/Glimpse.Mvc5.MusicStore.Sample.csproj
  30. +1 −0 source/Glimpse.Mvc5.MusicStore.Sample/Global.asax
  31. +32 −0 source/Glimpse.Mvc5.MusicStore.Sample/Global.asax.cs
  32. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/accent.png
  33. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/bullet.png
  34. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/heroAccent.png
  35. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/home-showcase.png
  36. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/logo.png
  37. +303 −0 source/Glimpse.Mvc5.MusicStore.Sample/Images/logo.svg
  38. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/orderedList0.png
  39. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/orderedList1.png
  40. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/orderedList2.png
  41. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/orderedList3.png
  42. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/orderedList4.png
  43. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/orderedList5.png
  44. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/orderedList6.png
  45. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/orderedList7.png
  46. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/orderedList8.png
  47. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/orderedList9.png
  48. BIN source/Glimpse.Mvc5.MusicStore.Sample/Images/placeholder.png
  49. +112 −0 source/Glimpse.Mvc5.MusicStore.Sample/Images/placeholder.svg
  50. +97 −0 source/Glimpse.Mvc5.MusicStore.Sample/Models/AccountModels.cs
  51. +37 −0 source/Glimpse.Mvc5.MusicStore.Sample/Models/Album.cs
  52. +13 −0 source/Glimpse.Mvc5.MusicStore.Sample/Models/Artist.cs
  53. +19 −0 source/Glimpse.Mvc5.MusicStore.Sample/Models/Cart.cs
  54. +12 −0 source/Glimpse.Mvc5.MusicStore.Sample/Models/Genre.cs
  55. +19 −0 source/Glimpse.Mvc5.MusicStore.Sample/Models/MusicStoreEntities.cs
  56. +68 −0 source/Glimpse.Mvc5.MusicStore.Sample/Models/Order.cs
  57. +14 −0 source/Glimpse.Mvc5.MusicStore.Sample/Models/OrderDetail.cs
  58. +827 −0 source/Glimpse.Mvc5.MusicStore.Sample/Models/SampleData.cs
  59. +195 −0 source/Glimpse.Mvc5.MusicStore.Sample/Models/ShoppingCart.cs
  60. +36 −0 source/Glimpse.Mvc5.MusicStore.Sample/Properties/AssemblyInfo.cs
  61. BIN source/Glimpse.Mvc5.MusicStore.Sample/Scripts/_references.js
  62. +2,657 −0 source/Glimpse.Mvc5.MusicStore.Sample/Scripts/jquery-1.9.1.intellisense.js
  63. +9,597 −0 source/Glimpse.Mvc5.MusicStore.Sample/Scripts/jquery-1.9.1.js
  64. +5 −0 source/Glimpse.Mvc5.MusicStore.Sample/Scripts/jquery-1.9.1.min.js
  65. +1 −0 source/Glimpse.Mvc5.MusicStore.Sample/Scripts/jquery-1.9.1.min.map
  66. +184 −0 source/Glimpse.Mvc5.MusicStore.Sample/Scripts/jquery.unobtrusive-ajax.js
  67. +5 −0 source/Glimpse.Mvc5.MusicStore.Sample/Scripts/jquery.unobtrusive-ajax.min.js
  68. +1,288 −0 source/Glimpse.Mvc5.MusicStore.Sample/Scripts/jquery.validate-vsdoc.js
  69. +1,207 −0 source/Glimpse.Mvc5.MusicStore.Sample/Scripts/jquery.validate.js
  70. +4 −0 source/Glimpse.Mvc5.MusicStore.Sample/Scripts/jquery.validate.min.js
  71. +394 −0 source/Glimpse.Mvc5.MusicStore.Sample/Scripts/jquery.validate.unobtrusive.js
  72. +5 −0 source/Glimpse.Mvc5.MusicStore.Sample/Scripts/jquery.validate.unobtrusive.min.js
  73. +1,406 −0 source/Glimpse.Mvc5.MusicStore.Sample/Scripts/modernizr-2.7.2.js
  74. +11 −0 source/Glimpse.Mvc5.MusicStore.Sample/ViewModels/ShoppingCartRemoveViewModel.cs
  75. +11 −0 source/Glimpse.Mvc5.MusicStore.Sample/ViewModels/ShoppingCartViewModel.cs
  76. +36 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Account/ExternalLoginConfirmation.cshtml
  77. +8 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Account/ExternalLoginFailure.cshtml
  78. +50 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Account/Login.cshtml
  79. +32 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Account/Manage.cshtml
  80. +37 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Account/Register.cshtml
  81. +27 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Account/_ChangePasswordPartial.cshtml
  82. +25 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Account/_ExternalLoginsListPartial.cshtml
  83. +34 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Account/_RemoveExternalLoginsPartial.cshtml
  84. +26 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Account/_SetPasswordPartial.cshtml
  85. +9 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/AttributeRoutingTest/AttrRouteTest.cshtml
  86. +13 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/AttributeRoutingTest/Index.cshtml
  87. +32 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Checkout/AddressAndPayment.cshtml
  88. +13 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Checkout/Complete.cshtml
  89. +18 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/FileUpload/Create.cshtml
  90. +13 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/FileUpload/Index.cshtml
  91. +34 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Home/About.cshtml
  92. +50 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Home/Contact.cshtml
  93. +21 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Home/Index.cshtml
  94. +80 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/ModelBindingTests/Index.cshtml
  95. +11 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Shared/Error.cshtml
  96. +53 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Shared/_Layout.cshtml
  97. +14 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Shared/_LoginPartial.cshtml
  98. +8 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/ShoppingCart/CartSummary.cshtml
  99. +91 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/ShoppingCart/Index.cshtml
  100. +23 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Store/Browse.cshtml
  101. +30 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Store/Details.cshtml
  102. +16 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Store/GenreMenu.cshtml
  103. +14 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Store/Index.cshtml
  104. +67 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/StoreManager/Create.cshtml
  105. +21 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/StoreManager/Delete.cshtml
  106. +50 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/StoreManager/Details.cshtml
  107. +69 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/StoreManager/Edit.cshtml
  108. +61 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/StoreManager/Index.cshtml
  109. +59 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/Web.config
  110. +3 −0 source/Glimpse.Mvc5.MusicStore.Sample/Views/_ViewStart.cshtml
  111. +30 −0 source/Glimpse.Mvc5.MusicStore.Sample/Web.Debug.config
  112. +31 −0 source/Glimpse.Mvc5.MusicStore.Sample/Web.Release.config
  113. +199 −0 source/Glimpse.Mvc5.MusicStore.Sample/Web.config
  114. BIN source/Glimpse.Mvc5.MusicStore.Sample/favicon.ico
  115. +31 −0 source/Glimpse.Mvc5.MusicStore.Sample/packages.config
  116. +48 −3 ...e/Glimpse.Test.AspNet/AlternateType/{RouteBaseGetRouteDataShould.cs → RouteGetRouteDataShould.cs}
  117. +21 −0 source/Glimpse.Test.AspNet/AlternateType/RouteShould .cs
  118. +2 −2 source/Glimpse.Test.AspNet/Glimpse.Test.AspNet.csproj
  119. +15 −15 source/Glimpse.Test.AspNet/Inspector/RoutesInspectorShould.cs
  120. +10 −9 source/Glimpse.Test.AspNet/Tab/RoutesShould.cs
View
@@ -112,6 +112,7 @@ Project("{CC5FD16D-436D-48AD-A40C-5A424C6E3E79}") = "Glimpse.WindowsAzure.Sample
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Glimpse.WindowsAzure.WebRole.Sample", "source\Glimpse.WindowsAzure.WebRole.Sample\Glimpse.WindowsAzure.WebRole.Sample.csproj", "{FE76DB8B-5FE3-4F25-B816-4EF2E6F20FFB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Glimpse.Mvc5.MusicStore.Sample", "source\Glimpse.Mvc5.MusicStore.Sample\Glimpse.Mvc5.MusicStore.Sample.csproj", "{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".items", ".items", "{EC933034-7250-4B53-A041-0D5DF203712B}"
ProjectSection(SolutionItems) = preProject
source\Settings.StyleCop = source\Settings.StyleCop
@@ -577,6 +578,16 @@ Global
{FE76DB8B-5FE3-4F25-B816-4EF2E6F20FFB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{FE76DB8B-5FE3-4F25-B816-4EF2E6F20FFB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{FE76DB8B-5FE3-4F25-B816-4EF2E6F20FFB}.Release|x86.ActiveCfg = Release|Any CPU
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}.Debug|x86.ActiveCfg = Debug|Any CPU
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}.Release|Any CPU.Build.0 = Release|Any CPU
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -586,6 +597,7 @@ Global
{C2C38EE9-01B7-4929-B7E9-086077D1AB58} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{214472C2-5C93-440A-8E14-BADC49CA6FE6} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{4288D838-C35F-4226-AEAD-766A19CF31CD} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{B373218F-19BB-4D5E-9EA7-000FDFD9BE5D} = {CCFACE51-18FA-4C5D-9F89-EC58881786A9}
{9923BFBD-EA73-4719-A418-213003862550} = {A3097EAF-9D1B-416A-822E-F679D768BC55}
{76714E46-AFE9-49F0-AEE8-C8A966195914} = {A3097EAF-9D1B-416A-822E-F679D768BC55}
{FE12BC0C-CD22-4D24-BFC7-13ED1C428BAD} = {A3097EAF-9D1B-416A-822E-F679D768BC55}
@@ -0,0 +1,257 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using Glimpse.AspNet.Message;
using Glimpse.Core.Extensibility;
using Glimpse.Core.Message;
namespace Glimpse.AspNet.AlternateType
{
public class Route : IAlternateType<System.Web.Routing.Route>
{
private readonly RouteConstraint routeConstraintAlternate;
private IEnumerable<IAlternateMethod> allMethodsRouteBase;
private IEnumerable<IAlternateMethod> allMethodsRoute;
public Route(IProxyFactory proxyFactory, ILogger logger)
{
ProxyFactory = proxyFactory;
Logger = logger;
routeConstraintAlternate = new RouteConstraint(proxyFactory);
}
public IEnumerable<IAlternateMethod> AllMethodsRouteBase
{
get
{
return allMethodsRouteBase ?? (allMethodsRouteBase = new List<IAlternateMethod>
{
new GetRouteData(typeof(System.Web.Routing.RouteBase)),
new GetVirtualPath(typeof(System.Web.Routing.RouteBase))
});
}
}
public IEnumerable<IAlternateMethod> AllMethodsRoute
{
get
{
return allMethodsRoute ?? (allMethodsRoute = new List<IAlternateMethod>
{
new GetRouteData(typeof(System.Web.Routing.Route)),
new GetVirtualPath(typeof(System.Web.Routing.Route)),
new ProcessConstraint(),
});
}
}
private IProxyFactory ProxyFactory { get; set; }
private ILogger Logger { get; set; }
public bool TryCreate(System.Web.Routing.Route originalObj, out System.Web.Routing.Route newObj)
{
return TryCreate(originalObj, out newObj, null, null);
}
public bool TryCreate(System.Web.Routing.Route originalObj, out System.Web.Routing.Route newObj, IEnumerable<object> mixins)
{
return TryCreate(originalObj, out newObj, mixins, null);
}
public bool TryCreate(System.Web.Routing.Route originalObj, out System.Web.Routing.Route newObj, IEnumerable<object> mixins, object[] constructorArguments)
{
newObj = null;
var route = originalObj as System.Web.Routing.Route;
if (route != null)
{
if (originalObj.GetType() == typeof(System.Web.Routing.Route))
{
newObj = ProxyFactory.ExtendClass<System.Web.Routing.Route>(AllMethodsRoute, mixins, new object[] { route.Url, route.Defaults, route.Constraints, route.DataTokens, route.RouteHandler });
}
else if (ProxyFactory.IsWrapClassEligible(typeof(System.Web.Routing.Route)))
{
newObj = ProxyFactory.WrapClass(route, AllMethodsRoute, mixins, new object[] { route.Url, route.Defaults, route.Constraints, route.DataTokens, route.RouteHandler });
SetupConstraints(Logger, ProxyFactory, route.Constraints);
}
}
if (newObj == null)
{
if (ProxyFactory.IsWrapClassEligible(typeof(System.Web.Routing.RouteBase)))
{
newObj = ProxyFactory.WrapClass(originalObj, AllMethodsRouteBase, mixins);
}
}
return newObj != null;
}
private void SetupConstraints(ILogger logger, IProxyFactory proxyFactory, System.Web.Routing.RouteValueDictionary constraints)
{
if (constraints != null)
{
var keys = constraints.Keys.ToList();
for (var i = 0; i < keys.Count; i++)
{
var constraintKey = keys[i];
var constraint = constraints[constraintKey];
var originalObj = constraint as System.Web.Routing.IRouteConstraint;
var newObj = (System.Web.Routing.IRouteConstraint)null;
if (originalObj == null)
{
var stringRouteConstraint = constraint as string;
if (stringRouteConstraint != null)
{
newObj = new RouteConstraintRegex(stringRouteConstraint);
}
}
else
{
routeConstraintAlternate.TryCreate(originalObj, out newObj);
}
if (newObj != null)
{
constraints[constraintKey] = newObj;
logger.Info(Resources.RouteSetupReplacedRoute, constraint.GetType());
}
else
{
logger.Info(Resources.RouteSetupNotReplacedRoute, constraint.GetType());
}
}
}
}
public class GetRouteData : AlternateMethod
{
public GetRouteData(Type type)
: base(type, "GetRouteData", BindingFlags.Public | BindingFlags.Instance)
{
}
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult)
{
var mixin = (IRouteNameMixin)context.Proxy;
context.MessageBroker.Publish(
new Message(context.Proxy.GetHashCode(), (System.Web.Routing.RouteData)context.ReturnValue, mixin.Name)
.AsTimedMessage(timerResult)
.AsSourceMessage(context.InvocationTarget.GetType(), context.MethodInvocationTarget));
}
public class Message : RouteDataMessage
{
public Message(int routeHashCode, System.Web.Routing.RouteData routeData, string routeName)
: base(routeHashCode, routeData, routeName)
{
}
}
}
public class GetVirtualPath : AlternateMethod
{
public GetVirtualPath(Type type)
: base(type, "GetVirtualPath", BindingFlags.Public | BindingFlags.Instance)
{
}
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult)
{
context.MessageBroker.Publish(new Message(
new Arguments(context.Arguments), context.InvocationTarget, (System.Web.Routing.VirtualPathData)context.ReturnValue)
.AsTimedMessage(timerResult)
.AsSourceMessage(context.InvocationTarget.GetType(), context.MethodInvocationTarget));
}
public class Arguments
{
public Arguments(params object[] args)
{
RequestContext = (System.Web.Routing.RequestContext)args[0];
Values = (System.Web.Routing.RouteValueDictionary)args[1];
}
public System.Web.Routing.RequestContext RequestContext { get; private set; }
public System.Web.Routing.RouteValueDictionary Values { get; private set; }
}
public class Message : ITimedMessage, ISourceMessage
{
public Message(Arguments args, object invocationTarget, System.Web.Routing.VirtualPathData virtualPathData)
{
IsMatch = virtualPathData != null;
RouteHashCode = invocationTarget.GetHashCode();
}
public int RouteHashCode { get; protected set; }
public bool IsMatch { get; protected set; }
public Guid Id { get; private set; }
public TimeSpan Offset { get; set; }
public TimeSpan Duration { get; set; }
public DateTime StartTime { get; set; }
public Type ExecutedType { get; set; }
public MethodInfo ExecutedMethod { get; set; }
}
}
public class ProcessConstraint : AlternateMethod
{
public ProcessConstraint()
: base(typeof(System.Web.Routing.Route), "ProcessConstraint", BindingFlags.NonPublic | BindingFlags.Instance)
{
}
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult)
{
context.MessageBroker.Publish(
new Message(new Arguments(context.Arguments), context.InvocationTarget.GetHashCode(), (bool)context.ReturnValue)
.AsTimedMessage(timerResult)
.AsSourceMessage(context.InvocationTarget.GetType(), context.MethodInvocationTarget));
}
public class Arguments
{
public Arguments(object[] args)
{
HttpContext = (HttpContextBase)args[0];
Constraint = args[1];
ParameterName = (string)args[2];
Values = (System.Web.Routing.RouteValueDictionary)args[3];
RouteDirection = (System.Web.Routing.RouteDirection)args[4];
}
public HttpContextBase HttpContext { get; private set; }
public object Constraint { get; private set; }
public string ParameterName { get; private set; }
public System.Web.Routing.RouteValueDictionary Values { get; private set; }
public System.Web.Routing.RouteDirection RouteDirection { get; private set; }
}
public class Message : ProcessConstraintMessage
{
public Message(Arguments args, int routeHashCode, bool isMatch)
: base(routeHashCode, args.Constraint.GetHashCode(), isMatch, args.ParameterName, args.Constraint, args.Values, args.RouteDirection)
{
}
}
}
}
}
@@ -145,37 +145,12 @@ public override void PostImplementation(IAlternateMethodContext context, TimerRe
.AsSourceMessage(context.InvocationTarget.GetType(), context.MethodInvocationTarget));
}
public class Message : MessageBase, ITimedMessage, ISourceMessage
public class Message : RouteDataMessage
{
public Message(int routeHashCode, System.Web.Routing.RouteData routeData, string routeName)
public Message(int routeHashCode, System.Web.Routing.RouteData routeData, string routeName)
: base(routeHashCode, routeData, routeName)
{
IsMatch = routeData != null;
RouteHashCode = routeHashCode;
RouteName = routeName;
if (routeData != null)
{
Values = routeData.Values;
}
}
public TimeSpan Offset { get; set; }
public TimeSpan Duration { get; set; }
public DateTime StartTime { get; set; }
public Type ExecutedType { get; set; }
public MethodInfo ExecutedMethod { get; set; }
public System.Web.Routing.RouteValueDictionary Values { get; protected set; }
public int RouteHashCode { get; protected set; }
public bool IsMatch { get; protected set; }
public string RouteName { get; protected set; }
}
}
@@ -49,6 +49,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AlternateType\IRouteNameMixin.cs" />
<Compile Include="AlternateType\Route.cs" />
<Compile Include="AlternateType\RouteBase.cs" />
<Compile Include="AlternateType\RouteConstraint.cs" />
<Compile Include="AlternateType\RouteConstraintRegex.cs" />
@@ -70,6 +71,7 @@
<Compile Include="HttpModule.cs" />
<Compile Include="HttpRuntimeShutdownMessageResolver.cs" />
<Compile Include="Message\ProcessConstraintMessage.cs" />
<Compile Include="Message\RouteDataMessage.cs" />
<Compile Include="Model\CacheConfigurationModel.cs" />
<Compile Include="Model\CacheItemModel.cs" />
<Compile Include="Model\CacheModel.cs" />
Oops, something went wrong.

0 comments on commit ca463a9

Please sign in to comment.