Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / xsp / System / Web / Extensions / Script / Services / RestHandlerFactory.cs / 1 / RestHandlerFactory.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.Script.Services {
internal class RestHandlerFactory : IHttpHandlerFactory {
internal const string ClientProxyRequestPathInfo = "/js";
internal const string ClientDebugProxyRequestPathInfo = "/jsdebug";
public virtual IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated) {
if (context == null) {
throw new ArgumentNullException("context");
}
if (IsClientProxyRequest(context.Request.PathInfo)) {
// It's a request for client side proxies
return new RestClientProxyHandler();
}
else {
// The request is an actual call to a server method
return RestHandler.CreateHandler(context);
}
}
public virtual void ReleaseHandler(IHttpHandler handler) {
}
// Detects if this is a request we want to intercept, i.e. invocation or proxy request
internal static bool IsRestRequest(HttpContext context) {
return IsRestMethodCall(context.Request) || IsClientProxyRequest(context.Request.PathInfo);
}
// Detects if this is a method invocation, i.e. webservice call or page method call
internal static bool IsRestMethodCall(HttpRequest request) {
return
!String.IsNullOrEmpty(request.PathInfo) &&
(request.ContentType.StartsWith("application/json;", StringComparison.OrdinalIgnoreCase) ||
string.Equals(request.ContentType, "application/json", StringComparison.OrdinalIgnoreCase));
}
internal static bool IsClientProxyDebugRequest(string pathInfo) {
return string.Equals(pathInfo, ClientDebugProxyRequestPathInfo, StringComparison.OrdinalIgnoreCase);
}
internal static bool IsClientProxyRequest(string pathInfo) {
return (string.Equals(pathInfo, ClientProxyRequestPathInfo, StringComparison.OrdinalIgnoreCase) ||
IsClientProxyDebugRequest(pathInfo));
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.Script.Services {
internal class RestHandlerFactory : IHttpHandlerFactory {
internal const string ClientProxyRequestPathInfo = "/js";
internal const string ClientDebugProxyRequestPathInfo = "/jsdebug";
public virtual IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated) {
if (context == null) {
throw new ArgumentNullException("context");
}
if (IsClientProxyRequest(context.Request.PathInfo)) {
// It's a request for client side proxies
return new RestClientProxyHandler();
}
else {
// The request is an actual call to a server method
return RestHandler.CreateHandler(context);
}
}
public virtual void ReleaseHandler(IHttpHandler handler) {
}
// Detects if this is a request we want to intercept, i.e. invocation or proxy request
internal static bool IsRestRequest(HttpContext context) {
return IsRestMethodCall(context.Request) || IsClientProxyRequest(context.Request.PathInfo);
}
// Detects if this is a method invocation, i.e. webservice call or page method call
internal static bool IsRestMethodCall(HttpRequest request) {
return
!String.IsNullOrEmpty(request.PathInfo) &&
(request.ContentType.StartsWith("application/json;", StringComparison.OrdinalIgnoreCase) ||
string.Equals(request.ContentType, "application/json", StringComparison.OrdinalIgnoreCase));
}
internal static bool IsClientProxyDebugRequest(string pathInfo) {
return string.Equals(pathInfo, ClientDebugProxyRequestPathInfo, StringComparison.OrdinalIgnoreCase);
}
internal static bool IsClientProxyRequest(string pathInfo) {
return (string.Equals(pathInfo, ClientProxyRequestPathInfo, StringComparison.OrdinalIgnoreCase) ||
IsClientProxyDebugRequest(pathInfo));
}
}
}
// 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
- FolderBrowserDialog.cs
- RoleService.cs
- TitleStyle.cs
- RandomNumberGenerator.cs
- SafeFileMappingHandle.cs
- Monitor.cs
- WpfWebRequestHelper.cs
- HostedTransportConfigurationManager.cs
- ToolStripStatusLabel.cs
- MenuItem.cs
- RepeatInfo.cs
- StylusPointPropertyInfoDefaults.cs
- IgnoreFileBuildProvider.cs
- PropertyKey.cs
- PreservationFileReader.cs
- TreeNode.cs
- GZipStream.cs
- path.cs
- DataConnectionHelper.cs
- SmiEventSink.cs
- ConfigurationElementCollection.cs
- ClientSession.cs
- ExitEventArgs.cs
- SqlGenerator.cs
- SqlClientWrapperSmiStream.cs
- AssemblyAttributesGoHere.cs
- WebPartConnectionsCancelVerb.cs
- UnsafeNativeMethods.cs
- WebPartPersonalization.cs
- ModelFunction.cs
- TextPattern.cs
- WindowsMenu.cs
- Nullable.cs
- DataListItemCollection.cs
- DesignUtil.cs
- TcpClientCredentialType.cs
- M3DUtil.cs
- ColorInterpolationModeValidation.cs
- UnmanagedMemoryStreamWrapper.cs
- AsymmetricSignatureFormatter.cs
- DependencyProperty.cs
- QueryOutputWriter.cs
- ProcessThreadCollection.cs
- HtmlTitle.cs
- AnnouncementEndpoint.cs
- FontEmbeddingManager.cs
- ToggleProviderWrapper.cs
- HTTPNotFoundHandler.cs
- ComponentResourceKeyConverter.cs
- GlobalizationAssembly.cs
- IERequestCache.cs
- ReliableInputConnection.cs
- SchemaConstraints.cs
- WindowsSspiNegotiation.cs
- ToolStripStatusLabel.cs
- PreviewControlDesigner.cs
- ContextDataSource.cs
- ImageDrawing.cs
- BooleanStorage.cs
- PopupRootAutomationPeer.cs
- XmlSchemas.cs
- RenderOptions.cs
- LinqDataSourceEditData.cs
- ClassImporter.cs
- Dispatcher.cs
- PageRequestManager.cs
- Geometry.cs
- UrlAuthorizationModule.cs
- SuspendDesigner.cs
- X500Name.cs
- Geometry.cs
- PasswordRecoveryAutoFormat.cs
- HtmlInputSubmit.cs
- SemanticResultKey.cs
- DataGridColumnDropSeparator.cs
- XmlSubtreeReader.cs
- TreeChangeInfo.cs
- PointLightBase.cs
- Reference.cs
- XmlIlGenerator.cs
- PersistNameAttribute.cs
- HtmlToClrEventProxy.cs
- SortKey.cs
- SecurityState.cs
- QilExpression.cs
- xmlfixedPageInfo.cs
- NetworkStream.cs
- DrawingBrush.cs
- EarlyBoundInfo.cs
- InstalledVoice.cs
- SubclassTypeValidator.cs
- LiteralTextParser.cs
- DataGridViewCellParsingEventArgs.cs
- SqlDataSourceCommandEventArgs.cs
- DesignerRegionMouseEventArgs.cs
- SubstitutionDesigner.cs
- ModelFactory.cs
- ImageButton.cs
- SpecialNameAttribute.cs
- SvcMapFileSerializer.cs