Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / System.ServiceModel.Activation / System / ServiceModel / Activation / ServiceRoute.cs / 1305376 / ServiceRoute.cs
//------------------------------------------------------------
// 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;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------
// 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;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FastPropertyAccessor.cs
- X509ClientCertificateAuthenticationElement.cs
- CompilationLock.cs
- X509Certificate.cs
- XmlBufferReader.cs
- ContextActivityUtils.cs
- ToolStripGrip.cs
- ResourceAttributes.cs
- PartialCachingAttribute.cs
- Stack.cs
- ConfigurationValidatorAttribute.cs
- SemanticBasicElement.cs
- FilterEventArgs.cs
- ProfileSettings.cs
- TemplateNameScope.cs
- PrintDialog.cs
- AttributedMetaModel.cs
- SqlDataSourceEnumerator.cs
- SizeChangedInfo.cs
- ConnectorDragDropGlyph.cs
- NullableBoolConverter.cs
- X509SecurityTokenProvider.cs
- UInt64Converter.cs
- DataSourceControlBuilder.cs
- DbConnectionClosed.cs
- StateItem.cs
- Ref.cs
- BaseTemplateParser.cs
- PropertyDescriptorComparer.cs
- BindingsCollection.cs
- IntPtr.cs
- XmlChildEnumerator.cs
- DataTableReaderListener.cs
- SqlExpressionNullability.cs
- NameSpaceEvent.cs
- FormViewPageEventArgs.cs
- DragCompletedEventArgs.cs
- AffineTransform3D.cs
- TextPointer.cs
- GridViewDeletedEventArgs.cs
- HttpMethodConstraint.cs
- DrawingAttributesDefaultValueFactory.cs
- ImagingCache.cs
- StylusPlugInCollection.cs
- MailFileEditor.cs
- clipboard.cs
- DataViewSettingCollection.cs
- GroupStyle.cs
- PolyBezierSegment.cs
- Math.cs
- DrawToolTipEventArgs.cs
- PersonalizableAttribute.cs
- BaseValidator.cs
- XmlAnyAttributeAttribute.cs
- ToolTipService.cs
- TextRunCacheImp.cs
- RemotingService.cs
- DataControlButton.cs
- GlyphShapingProperties.cs
- UnmanagedBitmapWrapper.cs
- X509Utils.cs
- ProfilePropertyNameValidator.cs
- JsonUriDataContract.cs
- XmlSchemaNotation.cs
- ListMarkerLine.cs
- EnglishPluralizationService.cs
- GradientStop.cs
- Proxy.cs
- DiagnosticEventProvider.cs
- NestedContainer.cs
- CalculatedColumn.cs
- ExtensionSurface.cs
- EmptyCollection.cs
- GridViewCellAutomationPeer.cs
- IndexedSelectQueryOperator.cs
- DataKeyCollection.cs
- SafeViewOfFileHandle.cs
- Repeater.cs
- PropertyEntry.cs
- CopyAttributesAction.cs
- BaseTypeViewSchema.cs
- TypeValidationEventArgs.cs
- VirtualPath.cs
- ConnectionStringSettings.cs
- PersonalizableTypeEntry.cs
- CachedRequestParams.cs
- PeerPresenceInfo.cs
- ManipulationLogic.cs
- IntSecurity.cs
- OleDbParameterCollection.cs
- DeferrableContent.cs
- XamlSerializerUtil.cs
- BufferedMessageWriter.cs
- Inline.cs
- PermissionSetEnumerator.cs
- StorageInfo.cs
- QueryReaderSettings.cs
- ResourceReferenceKeyNotFoundException.cs
- BuildProviderCollection.cs
- RMEnrollmentPage3.cs