Created
July 15, 2011 09:09
-
-
Save rarous/1084363 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class GuidConstraint : IRouteConstraint | |
| { | |
| public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) | |
| { | |
| if (!values.ContainsKey(parameterName)) | |
| return false; | |
| string stringValue = values[parameterName] as string; | |
| if (string.IsNullOrEmpty(stringValue)) | |
| return false; | |
| Guid guidValue; | |
| return Guid.TryParse(stringValue, out guidValue) && (guidValue != Guid.Empty); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class GuidConstraint : IRouteConstraint { | |
| public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) | |
| { | |
| if (values.ContainsKey(parameterName)) | |
| { | |
| string stringValue = values[parameterName] as string; | |
| if (!string.IsNullOrEmpty(stringValue)) | |
| { | |
| Guid guidValue; | |
| return Guid.TryParse(stringValue, out guidValue) && (guidValue != Guid.Empty); | |
| } | |
| } | |
| return false; | |
| }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment