Imported Upstream version 4.3.2.467

Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
Xamarin Public Jenkins
2016-02-22 11:00:01 -05:00
parent f302175246
commit f3e3aab35a
4097 changed files with 122406 additions and 82300 deletions

View File

@@ -6,21 +6,8 @@ LIBRARY = System.Web.Routing.dll
LIB_REFS = System System.Core System.Web System.Web.Abstractions
LIB_MCS_FLAGS =
ifdef DEBUG
LIB_MCS_FLAGS += -define:DEBUG
endif
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
EXTRA_DISTFILES =
# This is a .NET 3.5+ assembly
VALID_PROFILE := $(filter net_4_5, $(PROFILE))
ifndef VALID_PROFILE
LIBRARY_NAME = dummy-System.Web.Routing.dll
NO_INSTALL = yes
NO_SIGN_ASSEMBLY = yes
NO_TEST = yes
endif
include ../../build/library.make

View File

@@ -1,22 +1,3 @@
../../build/common/Consts.cs
../../build/common/MonoTODOAttribute.cs
Assembly/AssemblyInfo.cs
System.Web.Routing/HttpMethodConstraint.cs
System.Web.Routing/IRouteConstraint.cs
System.Web.Routing/IRouteHandler.cs
System.Web.Routing/PatternParser.cs
System.Web.Routing/PatternToken.cs
System.Web.Routing/PatternTokenType.cs
System.Web.Routing/RequestContext.cs
System.Web.Routing/Route.cs
System.Web.Routing/RouteBase.cs
System.Web.Routing/RouteCollection.cs
System.Web.Routing/RouteData.cs
System.Web.Routing/RouteDirection.cs
System.Web.Routing/RouteTable.cs
System.Web.Routing/RouteValueDictionary.cs
System.Web.Routing/RouteValueDictionaryExtensions.cs
System.Web.Routing/StopRoutingHandler.cs
System.Web.Routing/UrlRoutingHandler.cs
System.Web.Routing/UrlRoutingModule.cs
System.Web.Routing/VirtualPathData.cs

View File

@@ -1,225 +0,0 @@
2010-06-05 Marek Habersack <mhabersack@novell.com>
* UrlRoutingModule.cs: 4.0 doesn't do the UrlRouting.axd magic, it
simply remaps the current handler to the one obtained from the
route.
2010-05-06 Marek Habersack <mhabersack@novell.com>
* RouteCollection.cs: GetVirtualPath throws ArgumentException
when named route is not found in the collection.
2010-05-05 Marek Habersack <mhabersack@novell.com>
* UrlRoutingModule.cs: PostMapRequestHandler is obsolete in 4.0
* RouteValueDictionary.cs: do not process type fields in
RouteValueDictionary (object)
* RouteCollection.cs: GetRouteData throws an exception if Request
is null in the passed context.
Added Ignore* and MapPageRoute* 4.0 APIs
* RequestContext.cs: 4.0 API update
* PatternParser.cs: match parser rewrite to encompass 4.0 bug
fixes. We don't emulate some of the pre-4.0 routing bugs anymore.
2009-11-23 Marek Habersack <mhabersack@novell.com>
* Route.cs: GetRouteData throws NotImplementedException only when
pathInfo for the current request is a non-empty string. Patch from
Tiaan <tagdev@gmail.com>, thanks!
2009-11-09 Marek Habersack <mhabersack@novell.com>
* RouteCollection.cs: GetVirtualPath doesn't append trailing slash
to application path blindly anymore. Fixes bug #553022
2009-09-09 Marek Habersack <mhabersack@novell.com>
* Route.cs: when Url is set to null, create a parser for empty
string. Fixes bug #537751
* PatternParser.cs: Parse allows for null/empty URLs. Fixes bug
#537751
2009-09-08 Marek Habersack <mhabersack@novell.com>
* UrlRoutingModule.cs: store original request path in
PostResolveRequestCache and restore it in
PostMapRequestHandler. Fixes bug #537089
2009-08-19 Marek Habersack <mhabersack@novell.com>
* Route.cs: GetRouteData adds contents of its DataTokens
dictionary to the returned RouteData.DataTokens dictionary. Fixes
bug #523330. Patch from Dax@daxxfiles.net, thanks!
2009-06-25 Marek Habersack <mhabersack@novell.com>
* PatternParser.cs: parameter name lookups must be
case-insensitive.
Null and empty (string) parameters are skipped when building query
part of the action path.
2009-06-16 Marek Habersack <mhabersack@novell.com>
* RouteValueDictionaryExtensions.cs: do not compile if
SYSTEMCORE_DEP is not defined
* PatternParser.cs: if SYSTEMCORE_DEP is not defined, do not
compile parts which require RouteValueDictionaryExtensions.
* Decorated all classes with the TypeForwardedFrom attribute for
the 4.0 profile.
2009-06-04 Marek Habersack <mhabersack@novell.com>
* RouteValueDictionaryExtensions.cs: if both values are strings in
Has (string, value), compare them case-insensitively. Fixes bug
#502555
2009-05-27 Marek Habersack <mhabersack@novell.com>
* PatternParser.cs: if Match is passed an empty path, do not
attempt to match the Url segments, skip to defaults matching right
away.
2009-05-25 Marek Habersack <mhabersack@novell.com>
* UrlPattern.cs: removed - replaced by PatternParser below.
* RouteValueDictionaryExtensions.cs: added - some shortcuts for
using RouteValueDictionary in PatternParser
* Route.cs: use the new PatternParser.
Factored out ProcessConstraint into ProcessConstraintInternal so
that the latter can be used by the PatternParser class.
Added parameter checks in ProcessConstraint.
* PatternTokenType.cs: added
* PatternToken.cs: added a helper class for the pattern parser.
* PatternParser.cs: added. New implementation of url
parser/matcher/generator which fixes all URL isues known so
far. Fixes bug #504378
2009-05-12 Gonzalo Paniagua Javier <gonzalo@novell.com>
* UrlPattern.cs: if the pattern is line {a}/{b} and {b} is substituted
by an empty string, remove the '/' too.
2009-05-12 Gonzalo Paniagua Javier <gonzalo@novell.com>
* UrlPattern.cs: non-string default arguments work now.
2009-05-12 Marek Habersack <mhabersack@novell.com>
* UrlPattern.cs: TrySubstitute performs substitution trimming. If
a segment would be set to a default value and all of its following
segments as well, it will be omitted from the generated URL. The
value comparison is done case-insensitively when the dictionary
values are strings. Fixes bug #502555
2009-05-11 Marek Habersack <mhabersack@novell.com>
* UrlPattern.cs: TrySubstitute treats defaults differently
now. They are not consulted when checking if the passed values
match the pattern, but only when substituting the values. Fixes
bug #502555
2009-05-05 Marek Habersack <mhabersack@novell.com>
* UrlPattern.cs: Match adds defaults values should some keys be
missing from the url. Fixes bug #500739
* Route.cs: a small GetRouteData loop optimization
2009-02-18 Marek Habersack <mhabersack@novell.com>
* UrlPattern.cs: TrySubstitute now gets the collection of default
values and uses it to replace url segments instead of failing when
the passed values collection is missing a segment.
Do not use the tokens array in Match.
* RouteCollection.cs: check if name is null or empty, not just
null in GetVirtualPath
* Route.cs: url.TrySubstitute should be passed the defaults
collection when called from GetVirtualPath
2009-02-14 Marek Habersack <mhabersack@novell.com>
* UrlPattern.cs: use the defaults collection when matching a path
and segments are missing.
* RouteCollection.cs: GetRouteData must use VirtualPathProvider
to check for virtual path existence.
2008-10-23 Atsushi Enomoto <atsushi@ximian.com>
* UrlPattern.cs : fixed possible out-of-range case ("tableName/" in
DynamicData).
2008-10-17 Atsushi Enomoto <atsushi@ximian.com>
* RouteValueDictionary.cs : its string comparison is case
insensitive.
2008-10-17 Atsushi Enomoto <atsushi@ximian.com>
* UrlPattern.cs : fixed pattern match for such string that has
suffix. (DynamicData uses it.)
2008-10-16 Atsushi Enomoto <atsushi@ximian.com>
* RouteValueDictionary.cs : object argument is actually for
anonymous type instance.
2008-10-10 Atsushi Enomoto <atsushi@ximian.com>
* UrlRoutingModule.cs : implement PostMapRequestHandler() and
PostResolveRequestCache() to work correctly in order.
Now it should practically work.
2008-09-18 Atsushi Enomoto <atsushi@ximian.com>
* UrlRoutingModule.cs, RouteCollection.cs :
handle RouteExistingFiles.
2008-09-18 Atsushi Enomoto <atsushi@ximian.com>
* Route.cs : reject invalid constraint.
* UrlRoutingHandler.cs : more ProcessRequest() impl.
* UrlRoutingModule.cs : note.
2008-09-17 Atsushi Enomoto <atsushi@ximian.com>
* HttpMethodConstraint.cs, Route.cs, RouteCollection.cs,
UrlPattern.cs, UrlRoutingModule.cs:
ongoing UrlRoutingModule implementation.
2008-09-12 Atsushi Enomoto <atsushi@ximian.com>
* HttpMethodConstraint.cs, Route.cs, UrlPattern.cs,
RouteCollection.cs : implement Route.GetRouteData() and
HttpMethodConstraint.Match().
2008-09-12 Atsushi Enomoto <atsushi@ximian.com>
* UrlPattern.cs : new file for URL pattern processing.
* Route.cs : use above.
2008-09-11 Atsushi Enomoto <atsushi@ximian.com>
* HttpMethodConstraint.cs, RequestContext.cs, Route.cs,
RouteCollection.cs, RouteData.cs, RouteTable.cs,
RouteValueDictionary.cs, StopRoutingHandler.cs,
UrlRoutingHandler.cs, UrlRoutingModule.cs, VirtualPathData.cs:
some implementation.
2008-09-04 Atsushi Enomoto <atsushi@ximian.com>
*.cs: initial checkin.

View File

@@ -1,89 +0,0 @@
//
// HttpMethodConstraint.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Web;
namespace System.Web.Routing
{
[TypeForwardedFrom ("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class HttpMethodConstraint : IRouteConstraint
{
public HttpMethodConstraint (params string[] allowedMethods)
{
if (allowedMethods == null)
throw new ArgumentNullException ("allowedMethods");
AllowedMethods = allowedMethods;
}
public ICollection<string> AllowedMethods { get; private set; }
bool IRouteConstraint.Match (HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
return Match (httpContext, route, parameterName, values, routeDirection);
}
protected virtual bool Match (HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
if (httpContext == null)
throw new ArgumentNullException ("httpContext");
if (route == null)
throw new ArgumentNullException ("route");
if (parameterName == null)
throw new ArgumentNullException ("parameterName");
if (values == null)
throw new ArgumentNullException ("values");
switch (routeDirection) {
case RouteDirection.IncomingRequest:
// LAMESPEC: .NET allows case-insensitive comparison, which violates RFC 2616
return AllowedMethods.Contains (httpContext.Request.HttpMethod);
case RouteDirection.UrlGeneration:
// See: aspnetwebstack's WebAPI equivalent for details.
object method;
if (!values.TryGetValue (parameterName, out method))
return true;
// LAMESPEC: .NET allows case-insensitive comparison, which violates RFC 2616
return AllowedMethods.Contains (Convert.ToString (method));
default:
throw new ArgumentException ("Invalid routeDirection: " + routeDirection);
}
}
}
}

View File

@@ -1,42 +0,0 @@
//
// IRouteConstraint.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Web;
namespace System.Web.Routing
{
[TypeForwardedFrom ("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
public interface IRouteConstraint
{
bool Match (HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection);
}
}

View File

@@ -1,42 +0,0 @@
//
// IRouteHandler.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Web;
namespace System.Web.Routing
{
[TypeForwardedFrom ("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
public interface IRouteHandler
{
IHttpHandler GetHttpHandler (RequestContext requestContext);
}
}

View File

@@ -1,81 +0,0 @@
//
// PatternToken.cs
//
// Author:
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2009 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Text;
using System.Web;
namespace System.Web.Routing
{
sealed class PatternToken
{
public PatternTokenType Type {
get;
private set;
}
public string Name {
get;
private set;
}
public PatternToken (PatternTokenType type, string name)
{
this.Type = type;
this.Name = name;
}
public override string ToString ()
{
StringBuilder sb = new StringBuilder ();
switch (Type) {
case PatternTokenType.Standard:
sb.Append ("PatternToken_Standard");
break;
case PatternTokenType.Literal:
sb.Append ("PatternToken_Literal");
break;
case PatternTokenType.CatchAll:
sb.Append ("PatternToken_CatchAll");
break;
default:
sb.Append ("PatternToken_UNKNOWN");
break;
}
sb.AppendFormat (" [Name = '{0}']", Name);
return sb.ToString ();
}
}
}

View File

@@ -1,40 +0,0 @@
//
// PatternTokenType.cs
//
// Author:
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2009 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Web.Routing
{
enum PatternTokenType
{
Standard,
Literal,
CatchAll
}
}

View File

@@ -1,61 +0,0 @@
//
// RequestContext.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Web;
namespace System.Web.Routing
{
[TypeForwardedFrom ("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class RequestContext
{
public RequestContext ()
{
HttpContext = null;
RouteData = null;
}
public RequestContext (HttpContextBase httpContext, RouteData routeData)
{
if (httpContext == null)
throw new ArgumentNullException ("httpContext");
if (routeData == null)
throw new ArgumentNullException ("routeData");
HttpContext = httpContext;
RouteData = routeData;
}
public virtual HttpContextBase HttpContext { get; set; }
public virtual RouteData RouteData { get; set; }
}
}

View File

@@ -1,262 +0,0 @@
//
// Route.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using System.Web;
using System.Globalization;
namespace System.Web.Routing
{
[TypeForwardedFrom ("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class Route : RouteBase
{
static readonly Type httpRequestBaseType = typeof (HttpRequestBase);
PatternParser url;
public RouteValueDictionary Constraints { get; set; }
public RouteValueDictionary DataTokens { get; set; }
public RouteValueDictionary Defaults { get; set; }
public IRouteHandler RouteHandler { get; set; }
public string Url {
get { return url != null ? url.Url : String.Empty; }
set { url = value != null ? new PatternParser (value) : new PatternParser (String.Empty); }
}
public Route (string url, IRouteHandler routeHandler)
: this (url, null, routeHandler)
{
}
public Route (string url, RouteValueDictionary defaults, IRouteHandler routeHandler)
: this (url, defaults, null, routeHandler)
{
}
public Route (string url, RouteValueDictionary defaults, RouteValueDictionary constraints, IRouteHandler routeHandler)
: this (url, defaults, constraints, null, routeHandler)
{
}
public Route (string url, RouteValueDictionary defaults, RouteValueDictionary constraints, RouteValueDictionary dataTokens, IRouteHandler routeHandler)
{
Url = url;
Defaults = defaults;
Constraints = constraints;
DataTokens = dataTokens;
RouteHandler = routeHandler;
}
public override RouteData GetRouteData (HttpContextBase httpContext)
{
var path = httpContext.Request.AppRelativeCurrentExecutionFilePath;
var pathInfo = httpContext.Request.PathInfo;
if (!String.IsNullOrEmpty (pathInfo))
path += pathInfo;
// probably code like this causes ArgumentOutOfRangeException under .NET.
// It somehow allows such path that is completely equivalent to the Url. Dunno why.
if (Url != path && path.Substring (0, 2) != "~/")
return null;
path = path.Substring (2);
var values = url.Match (path, Defaults);
if (values == null)
return null;
if (!ProcessConstraints (httpContext, values, RouteDirection.IncomingRequest))
return null;
var rd = new RouteData (this, RouteHandler);
RouteValueDictionary rdValues = rd.Values;
foreach (var p in values)
rdValues.Add (p.Key, p.Value);
RouteValueDictionary dataTokens = DataTokens;
if (dataTokens != null) {
RouteValueDictionary rdDataTokens = rd.DataTokens;
foreach (var token in dataTokens)
rdDataTokens.Add (token.Key, token.Value);
}
return rd;
}
public override VirtualPathData GetVirtualPath (RequestContext requestContext, RouteValueDictionary values)
{
if (requestContext == null)
throw new ArgumentNullException ("requestContext");
if (url == null)
return new VirtualPathData (this, String.Empty);
// null values is allowed.
// if (values == null)
// values = requestContext.RouteData.Values;
RouteValueDictionary usedValues;
string resultUrl = url.BuildUrl (this, requestContext, values, Constraints, out usedValues);
if (resultUrl == null)
return null;
if (!ProcessConstraints (requestContext.HttpContext, usedValues, RouteDirection.UrlGeneration))
return null;
var result = new VirtualPathData (this, resultUrl);
RouteValueDictionary dataTokens = DataTokens;
if (dataTokens != null) {
foreach (var item in dataTokens)
result.DataTokens[item.Key] = item.Value;
}
return result;
}
private bool ProcessConstraintInternal (HttpContextBase httpContext, Route route, object constraint, string parameterName,
RouteValueDictionary values, RouteDirection routeDirection, RequestContext reqContext,
out bool invalidConstraint)
{
invalidConstraint = false;
IRouteConstraint irc = constraint as IRouteConstraint;
if (irc != null)
return irc.Match (httpContext, route, parameterName, values, routeDirection);
string s = constraint as string;
if (s != null) {
string v = null;
object o;
// NOTE: If constraint was not an IRouteConstraint, is is asumed
// to be an object 'convertible' to string, or at least this is how
// ASP.NET seems to work by the tests i've done latelly. (pruiz)
if (values != null && values.TryGetValue (parameterName, out o))
v = Convert.ToString (o, CultureInfo.InvariantCulture);
if (!String.IsNullOrEmpty (v))
return MatchConstraintRegex (v, s);
else if (reqContext != null) {
RouteData rd = reqContext != null ? reqContext.RouteData : null;
RouteValueDictionary rdValues = rd != null ? rd.Values : null;
if (rdValues == null || rdValues.Count == 0)
return false;
if (!rdValues.TryGetValue (parameterName, out o))
return false;
v = Convert.ToString (o, CultureInfo.InvariantCulture);
if (String.IsNullOrEmpty (v))
return false;
return MatchConstraintRegex (v, s);
}
return false;
}
invalidConstraint = true;
return false;
}
static bool MatchConstraintRegex (string value, string constraint)
{
int len = constraint.Length;
if (len > 0) {
// Bug #651966 - regexp constraints must be treated
// as absolute expressions
if (constraint [0] != '^') {
constraint = "^" + constraint;
len++;
}
if (constraint [len - 1] != '$')
constraint += "$";
}
return Regex.IsMatch (value, constraint, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.Compiled);
}
protected virtual bool ProcessConstraint (HttpContextBase httpContext, object constraint, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
if (parameterName == null)
throw new ArgumentNullException ("parameterName");
// .NET "compatibility"
if (values == null)
throw new NullReferenceException ();
RequestContext reqContext;
reqContext = SafeGetContext (httpContext != null ? httpContext.Request : null);
bool invalidConstraint;
bool ret = ProcessConstraintInternal (httpContext, this, constraint, parameterName, values, routeDirection, reqContext, out invalidConstraint);
if (invalidConstraint)
throw new InvalidOperationException (
String.Format (
"Constraint parameter '{0}' on the route with URL '{1}' must have a string value type or be a type which implements IRouteConstraint",
parameterName, Url
)
);
return ret;
}
private bool ProcessConstraints (HttpContextBase httpContext, RouteValueDictionary values, RouteDirection routeDirection)
{
var constraints = Constraints;
if (Constraints != null) {
foreach (var p in constraints)
if (!ProcessConstraint (httpContext, p.Value, p.Key, values, routeDirection))
return false;
}
return true;
}
RequestContext SafeGetContext (HttpRequestBase req)
{
if (req == null || req.GetType () != httpRequestBaseType)
return null;
return req.RequestContext;
}
}
}

View File

@@ -1,45 +0,0 @@
//
// RouteBase.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Web;
namespace System.Web.Routing
{
[TypeForwardedFrom ("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public abstract class RouteBase
{
public abstract RouteData GetRouteData (HttpContextBase httpContext);
public abstract VirtualPathData GetVirtualPath (RequestContext requestContext, RouteValueDictionary values);
}
}

View File

@@ -1,268 +0,0 @@
//
// RouteCollection.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Web;
using System.Web.Hosting;
namespace System.Web.Routing
{
[TypeForwardedFrom ("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class RouteCollection : Collection<RouteBase>
{
class Lock : IDisposable
{
//RouteCollection owner;
//bool read;
public Lock (RouteCollection owner, bool read)
{
//this.owner = owner;
//this.read = read;
}
public void Dispose ()
{
//if (read)
// owner.read_lock = null;
//else
// owner_write_lock = null;
}
}
public RouteCollection ()
: this (null)
{
}
public RouteCollection (VirtualPathProvider virtualPathProvider)
{
// null argument is allowed
//provider = virtualPathProvider;
read_lock = new Lock (this, true);
write_lock = new Lock (this, false);
}
//VirtualPathProvider provider;
Dictionary<string,RouteBase> d = new Dictionary<string,RouteBase> ();
Lock read_lock, write_lock;
public RouteBase this [string name] {
get {
foreach (var p in d)
if (p.Key == name)
return p.Value;
return null;
}
}
public bool LowercaseUrls { get; set; }
public bool AppendTrailingSlash { get; set; }
public bool RouteExistingFiles { get; set; }
public void Add (string name, RouteBase item)
{
lock (GetWriteLock ()) {
base.Add (item);
if (!String.IsNullOrEmpty (name))
d.Add (name, item);
}
}
protected override void ClearItems ()
{
lock (GetWriteLock ())
base.ClearItems ();
}
public IDisposable GetReadLock ()
{
return read_lock;
}
public RouteData GetRouteData (HttpContextBase httpContext)
{
if (httpContext == null)
throw new ArgumentNullException ("httpContext");
if (httpContext.Request == null)
throw new ArgumentException ("The context does not contain any request data.", "httpContext");
if (Count == 0)
return null;
if (!RouteExistingFiles) {
var path = httpContext.Request.AppRelativeCurrentExecutionFilePath;
VirtualPathProvider vpp = HostingEnvironment.VirtualPathProvider;
if (path != "~/" && vpp != null && (vpp.FileExists (path) || vpp.DirectoryExists (path)))
return null;
}
foreach (RouteBase rb in this) {
var rd = rb.GetRouteData (httpContext);
if (rd != null)
return rd;
}
return null;
}
public VirtualPathData GetVirtualPath (RequestContext requestContext, RouteValueDictionary values)
{
return GetVirtualPath (requestContext, null, values);
}
public VirtualPathData GetVirtualPath (RequestContext requestContext, string name, RouteValueDictionary values)
{
if (requestContext == null)
throw new ArgumentNullException ("httpContext");
VirtualPathData vp = null;
if (!String.IsNullOrEmpty (name)) {
RouteBase rb = this [name];
if (rb != null)
vp = rb.GetVirtualPath (requestContext, values);
else
throw new ArgumentException ("A route named '" + name + "' could not be found in the route collection.", "name");
} else {
foreach (RouteBase rb in this) {
vp = rb.GetVirtualPath (requestContext, values);
if (vp != null)
break;
}
}
if (vp != null) {
string appPath = requestContext.HttpContext.Request.ApplicationPath;
if (appPath != null && (appPath.Length == 0 || !appPath.EndsWith ("/", StringComparison.Ordinal)))
appPath += "/";
string pathWithApp = String.Concat (appPath, vp.VirtualPath);
vp.VirtualPath = requestContext.HttpContext.Response.ApplyAppPathModifier (pathWithApp);
return vp;
}
return null;
}
public IDisposable GetWriteLock ()
{
return write_lock;
}
public void Ignore (string url)
{
Ignore (url, null);
}
public void Ignore (string url, object constraints)
{
if (url == null)
throw new ArgumentNullException ("url");
Add (new Route (url, null, new RouteValueDictionary (constraints), new StopRoutingHandler ()));
}
public Route MapPageRoute (string routeName, string routeUrl, string physicalFile)
{
return MapPageRoute (routeName, routeUrl, physicalFile, true, null, null, null);
}
public Route MapPageRoute (string routeName, string routeUrl, string physicalFile, bool checkPhysicalUrlAccess)
{
return MapPageRoute (routeName, routeUrl, physicalFile, checkPhysicalUrlAccess, null, null, null);
}
public Route MapPageRoute (string routeName, string routeUrl, string physicalFile, bool checkPhysicalUrlAccess,
RouteValueDictionary defaults)
{
return MapPageRoute (routeName, routeUrl, physicalFile, checkPhysicalUrlAccess, defaults, null, null);
}
public Route MapPageRoute (string routeName, string routeUrl, string physicalFile, bool checkPhysicalUrlAccess,
RouteValueDictionary defaults, RouteValueDictionary constraints)
{
return MapPageRoute (routeName, routeUrl, physicalFile, checkPhysicalUrlAccess, defaults, constraints, null);
}
public Route MapPageRoute (string routeName, string routeUrl, string physicalFile, bool checkPhysicalUrlAccess,
RouteValueDictionary defaults, RouteValueDictionary constraints, RouteValueDictionary dataTokens)
{
if (routeUrl == null)
throw new ArgumentNullException ("routeUrl");
var route = new Route (routeUrl, defaults, constraints, dataTokens, new PageRouteHandler (physicalFile, checkPhysicalUrlAccess));
Add (routeName, route);
return route;
}
protected override void InsertItem (int index, RouteBase item)
{
// FIXME: what happens wrt its name?
lock (GetWriteLock ())
base.InsertItem (index, item);
}
protected override void RemoveItem (int index)
{
// FIXME: what happens wrt its name?
lock (GetWriteLock ()) {
string k = GetKey (index);
base.RemoveItem (index);
if (k != null)
d.Remove (k);
}
}
protected override void SetItem (int index, RouteBase item)
{
// FIXME: what happens wrt its name?
lock (GetWriteLock ()) {
string k = GetKey (index);
base.SetItem (index, item);
if (k != null)
d.Remove (k);
}
}
string GetKey (int index)
{
var item = this [index];
foreach (var p in d)
if (p.Value == item)
return p.Key;
return null;
}
}
}

View File

@@ -1,76 +0,0 @@
//
// RouteData.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Web;
namespace System.Web.Routing
{
[TypeForwardedFrom ("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class RouteData
{
public RouteData ()
: this (null, null)
{
}
public RouteData (RouteBase route, IRouteHandler routeHandler)
{
// arguments can be null.
Route = route;
RouteHandler = routeHandler;
DataTokens = new RouteValueDictionary ();
Values = new RouteValueDictionary ();
}
public RouteValueDictionary DataTokens { get; private set; }
public RouteBase Route { get; set; }
public IRouteHandler RouteHandler { get; set; }
public RouteValueDictionary Values { get; private set; }
public string GetRequiredString (string valueName)
{
object o;
if (!Values.TryGetValue (valueName, out o))
throw new InvalidOperationException (String.Format ("value name {0} does not match any of the values.", valueName));
string s = o as string;
if (String.IsNullOrEmpty (s))
throw new InvalidOperationException (String.Format ("The value for the name {0} must be a non-empty string", valueName));
return s;
}
}
}

View File

@@ -1,40 +0,0 @@
//
// RouteDirection.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.CompilerServices;
namespace System.Web.Routing
{
[TypeForwardedFrom ("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
public enum RouteDirection
{
IncomingRequest,
UrlGeneration
}
}

View File

@@ -1,49 +0,0 @@
//
// RouteTable.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Web;
namespace System.Web.Routing
{
[TypeForwardedFrom ("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class RouteTable
{
static RouteTable ()
{
Routes = new RouteCollection ();
}
public static RouteCollection Routes { get; private set; }
}
}

View File

@@ -1,184 +0,0 @@
//
// RouteValueDictionary.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Web;
using PairCollection = System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>>;
namespace System.Web.Routing
{
[TypeForwardedFrom ("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class RouteValueDictionary : IDictionary<string, object>
{
internal class CaseInsensitiveStringComparer : IEqualityComparer<string>
{
public static readonly CaseInsensitiveStringComparer Instance = new CaseInsensitiveStringComparer ();
public int GetHashCode (string obj)
{
return obj.ToLower (CultureInfo.InvariantCulture).GetHashCode ();
}
public bool Equals (string obj1, string obj2)
{
return String.Equals (obj1, obj2, StringComparison.OrdinalIgnoreCase);
}
}
Dictionary<string,object> d = new Dictionary<string,object> (CaseInsensitiveStringComparer.Instance);
public RouteValueDictionary ()
{
}
public RouteValueDictionary (IDictionary<string, object> dictionary)
{
if (dictionary == null)
throw new ArgumentNullException ("dictionary");
foreach (var p in dictionary)
Add (p.Key, p.Value);
}
public RouteValueDictionary (object values) // anonymous type instance
{
if (values == null)
return;
foreach (var pi in values.GetType ().GetProperties ()) {
try {
Add (pi.Name, pi.GetValue (values, null));
} catch {
// ignore
}
}
}
public int Count {
get { return d.Count; }
}
bool PairCollection.IsReadOnly {
get { return ((PairCollection) d).IsReadOnly; }
}
ICollection<string> IDictionary<string, object>.Keys {
get { return d.Keys; }
}
ICollection<Object> IDictionary<string, object>.Values {
get { return d.Values; }
}
public object this [string key] {
get { object v; return d.TryGetValue (key, out v) ? v : null; }
set { d [key] = value; }
}
public Dictionary<string, object>.KeyCollection Keys {
get { return d.Keys; }
}
public Dictionary<string, object>.ValueCollection Values {
get { return d.Values; }
}
public void Add (string key, object value)
{
d.Add (key, value);
}
public void Clear ()
{
d.Clear ();
}
public bool ContainsKey (string key)
{
return d.ContainsKey (key);
}
public bool ContainsValue (object value)
{
return d.ContainsValue (value);
}
public Dictionary<string, object>.Enumerator GetEnumerator ()
{
return d.GetEnumerator ();
}
void ICollection<KeyValuePair<string, object>>.Add (KeyValuePair<string, object> item)
{
((PairCollection) d).Add (item);
}
bool ICollection<KeyValuePair<string, object>>.Contains (KeyValuePair<string, object> item)
{
return ((PairCollection) d).Contains (item);
}
void ICollection<KeyValuePair<string, object>>.CopyTo (KeyValuePair<string, object> [] array, int arrayIndex)
{
((PairCollection) d).CopyTo (array, arrayIndex);
}
bool ICollection<KeyValuePair<string, object>>.Remove (KeyValuePair<string, object> item)
{
return ((PairCollection) d).Remove (item);
}
IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<string, object>>.GetEnumerator()
{
return d.GetEnumerator ();
}
IEnumerator IEnumerable.GetEnumerator ()
{
return d.GetEnumerator ();
}
public bool Remove (string key)
{
return d.Remove (key);
}
public bool TryGetValue (string key, out object value)
{
return d.TryGetValue (key, out value);
}
}
}

View File

@@ -1,101 +0,0 @@
//
// PatternParser.cs
//
// Author:
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2009 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if SYSTEMCORE_DEP
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace System.Web.Routing
{
static class RouteValueDictionaryExtensions
{
public static bool Has (this RouteValueDictionary dict, string key)
{
if (dict == null)
return false;
return dict.ContainsKey (key);
}
public static bool Has (this RouteValueDictionary dict, string key, object value)
{
if (dict == null)
return false;
object entryValue;
if (dict.TryGetValue (key, out entryValue)) {
if (value is string) {
if (!(entryValue is string))
return false;
string s1 = value as string;
string s2 = entryValue as string;
return String.Compare (s1, s2, StringComparison.OrdinalIgnoreCase) == 0;
}
return entryValue == null ? value == null : entryValue.Equals (value);
}
return false;
}
public static bool GetValue (this RouteValueDictionary dict, string key, out object value)
{
if (dict == null) {
value = null;
return false;
}
return dict.TryGetValue (key, out value);
}
[Conditional ("DEBUG")]
public static void Dump (this RouteValueDictionary dict, string name, string indent)
{
if (indent == null)
indent = String.Empty;
if (dict == null) {
Console.WriteLine (indent + "Dictionary '{0}' is null", name);
return;
}
if (dict.Count == 0) {
Console.WriteLine (indent + "Dictionary '{0}' is empty", name);
return;
}
Console.WriteLine (indent + "Dictionary '{0}':", name);
foreach (var de in dict)
Console.WriteLine (indent + "\t'{0}' == {1}", de.Key, de.Value);
}
}
}
#endif

View File

@@ -1,52 +0,0 @@
//
// StopRoutingHandler.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Web;
namespace System.Web.Routing
{
[TypeForwardedFrom ("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class StopRoutingHandler : IRouteHandler
{
protected virtual IHttpHandler GetHttpHandler (RequestContext requestContext)
{
throw new NotSupportedException ();
}
IHttpHandler IRouteHandler.GetHttpHandler (RequestContext requestContext)
{
return GetHttpHandler (requestContext);
}
}
}

View File

@@ -1,88 +0,0 @@
//
// UrlRoutingHandler.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008-2010 Novell Inc. http://novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Web;
namespace System.Web.Routing
{
[TypeForwardedFrom ("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public abstract class UrlRoutingHandler : IHttpHandler
{
RouteCollection routes;
bool IHttpHandler.IsReusable {
get { return IsReusable; }
}
protected virtual bool IsReusable { get { return false; } }
public RouteCollection RouteCollection {
get {
if (routes == null)
routes = RouteTable.Routes;
return routes;
}
set { routes = value; }
}
void IHttpHandler.ProcessRequest (HttpContext context)
{
ProcessRequest (context);
}
protected virtual void ProcessRequest (HttpContext httpContext)
{
ProcessRequest (new HttpContextWrapper (httpContext));
}
protected virtual void ProcessRequest (HttpContextBase httpContext)
{
if (httpContext == null)
throw new ArgumentNullException ("httpContext");
var rd = RouteCollection.GetRouteData (httpContext);
if (rd == null)
throw new HttpException ("The incoming request does not match any route");
if (rd.RouteHandler == null)
throw new InvalidOperationException ("No IRouteHandler is assigned to the selected route");
RequestContext rc = new RequestContext (httpContext, rd);
var hh = rd.RouteHandler.GetHttpHandler (rc);
VerifyAndProcessRequest (hh, httpContext);
}
protected abstract void VerifyAndProcessRequest (IHttpHandler httpHandler, HttpContextBase httpContext);
}
}

Some files were not shown because too many files have changed in this diff Show More