mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Adding reference source for System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.SqlXml System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Xml System.Xml.Linq
58 lines
2.5 KiB
C#
58 lines
2.5 KiB
C#
//------------------------------------------------------------
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
//------------------------------------------------------------
|
|
|
|
namespace System.ServiceModel.Activation
|
|
{
|
|
using System;
|
|
using System.Globalization;
|
|
using System.Web.Routing;
|
|
|
|
public class ServiceRoute : Route
|
|
{
|
|
internal const string LeftCurlyBracket = "{";
|
|
internal const string RightCurlyBracket = "}";
|
|
internal const string UnmatchedPathSegment = "{*pathInfo}";
|
|
internal const char PathSeperator = '/';
|
|
|
|
public ServiceRoute(string routePrefix, ServiceHostFactoryBase serviceHostFactory, Type serviceType)
|
|
: base(CheckAndCreateRouteString(routePrefix), new ServiceRouteHandler(routePrefix, serviceHostFactory, serviceType))
|
|
{
|
|
if (TD.AspNetRouteIsEnabled())
|
|
{
|
|
TD.AspNetRoute(routePrefix, serviceType.AssemblyQualifiedName, serviceHostFactory.GetType().AssemblyQualifiedName);
|
|
}
|
|
}
|
|
|
|
static string CheckAndCreateRouteString(string routePrefix)
|
|
{
|
|
// aspnet routing integration is supported only under aspnet compat mode
|
|
ServiceHostingEnvironment.EnsureInitialized();
|
|
if (!ServiceHostingEnvironment.AspNetCompatibilityEnabled)
|
|
{
|
|
throw FxTrace.Exception.AsError(new InvalidOperationException(SR.Hosting_RouteServiceRequiresCompatibilityMode));
|
|
}
|
|
// we support emptystring as routeprfix as aspnet allows it
|
|
if (routePrefix == null)
|
|
{
|
|
throw FxTrace.Exception.ArgumentNull("routePrefix");
|
|
}
|
|
else if (routePrefix.Contains(LeftCurlyBracket) || routePrefix.Contains(RightCurlyBracket))
|
|
{
|
|
throw FxTrace.Exception.Argument("routePrefix", SR.Hosting_CurlyBracketFoundInRoutePrefix("{", "}"));
|
|
}
|
|
|
|
if (routePrefix.EndsWith(PathSeperator.ToString(), StringComparison.CurrentCultureIgnoreCase)
|
|
|| routePrefix.Equals(String.Empty, StringComparison.CurrentCultureIgnoreCase))
|
|
{
|
|
routePrefix = string.Format(CultureInfo.CurrentCulture, "{0}{1}", routePrefix, UnmatchedPathSegment);
|
|
}
|
|
else
|
|
{
|
|
routePrefix = string.Format(CultureInfo.CurrentCulture, "{0}/{1}", routePrefix, UnmatchedPathSegment);
|
|
}
|
|
return routePrefix;
|
|
}
|
|
}
|
|
}
|