Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / Script / Services / ScriptHandlerFactory.cs / 1305376 / ScriptHandlerFactory.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System.Web.SessionState; using System.Security.Permissions; using System.Security; namespace System.Web.Script.Services { internal class ScriptHandlerFactory : IHttpHandlerFactory { IHttpHandlerFactory _restHandlerFactory; IHttpHandlerFactory _webServiceHandlerFactory; internal class HandlerWrapper : IHttpHandler { protected IHttpHandler _originalHandler; private IHttpHandlerFactory _originalFactory; internal HandlerWrapper(IHttpHandler originalHandler, IHttpHandlerFactory originalFactory) { _originalFactory = originalFactory; _originalHandler = originalHandler; } internal void ReleaseHandler() { _originalFactory.ReleaseHandler(_originalHandler); } public bool IsReusable { get { return _originalHandler.IsReusable; } } public void ProcessRequest(HttpContext context) { _originalHandler.ProcessRequest(context); } } internal class HandlerWrapperWithSession : HandlerWrapper, IRequiresSessionState { internal HandlerWrapperWithSession(IHttpHandler originalHandler, IHttpHandlerFactory originalFactory) : base(originalHandler, originalFactory) {} } private class AsyncHandlerWrapper : HandlerWrapper, IHttpAsyncHandler { internal AsyncHandlerWrapper(IHttpHandler originalHandler, IHttpHandlerFactory originalFactory) : base(originalHandler, originalFactory) { } public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { return ((IHttpAsyncHandler)_originalHandler).BeginProcessRequest(context, cb, extraData); } public void EndProcessRequest(IAsyncResult result) { ((IHttpAsyncHandler)_originalHandler).EndProcessRequest(result); } } private class AsyncHandlerWrapperWithSession : AsyncHandlerWrapper, IRequiresSessionState { internal AsyncHandlerWrapperWithSession(IHttpHandler originalHandler, IHttpHandlerFactory originalFactory) : base(originalHandler, originalFactory) { } } public ScriptHandlerFactory() { _restHandlerFactory = new RestHandlerFactory(); _webServiceHandlerFactory = new System.Web.Services.Protocols.WebServiceHandlerFactory(); } [SecuritySafeCritical] public virtual IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated) { IHttpHandler handler; IHttpHandlerFactory factory; if (RestHandlerFactory.IsRestRequest(context)) { // It's a REST request factory = _restHandlerFactory; } else { // It's a regular asmx web request, so delegate to the WebServiceHandlerFactory factory = _webServiceHandlerFactory; } handler = factory.GetHandler(context, requestType, url, pathTranslated); bool requiresSession = handler is IRequiresSessionState; if (handler is IHttpAsyncHandler) { if (requiresSession) return new AsyncHandlerWrapperWithSession(handler, factory); else return new AsyncHandlerWrapper(handler, factory); } if (requiresSession) return new HandlerWrapperWithSession(handler, factory); else return new HandlerWrapper(handler, factory); } public virtual void ReleaseHandler(IHttpHandler handler) { if (handler == null) { throw new ArgumentNullException("handler"); } ((HandlerWrapper)handler).ReleaseHandler(); } } } // 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
- HtmlTable.cs
- Match.cs
- SamlAuthorizationDecisionClaimResource.cs
- ChtmlTextBoxAdapter.cs
- FlowPosition.cs
- WebBrowserDesigner.cs
- DatatypeImplementation.cs
- CacheMode.cs
- ConditionalAttribute.cs
- XmlSequenceWriter.cs
- TickBar.cs
- CuspData.cs
- StrongNameKeyPair.cs
- Matrix.cs
- ReversePositionQuery.cs
- CalendarDay.cs
- RewritingPass.cs
- SqlLiftWhereClauses.cs
- EmbeddedMailObject.cs
- PropertySourceInfo.cs
- KeyGestureValueSerializer.cs
- ContextMenuStripGroupCollection.cs
- AccessControlEntry.cs
- HelpProvider.cs
- TraceData.cs
- Profiler.cs
- StronglyTypedResourceBuilder.cs
- figurelength.cs
- DispatcherProcessingDisabled.cs
- BitmapEffectInputConnector.cs
- TextPattern.cs
- RequestQueryProcessor.cs
- PreservationFileReader.cs
- ResXResourceWriter.cs
- BasePropertyDescriptor.cs
- SimpleLine.cs
- ReferentialConstraintRoleElement.cs
- InterleavedZipPartStream.cs
- XmlCharacterData.cs
- _HTTPDateParse.cs
- __Error.cs
- TypeDependencyAttribute.cs
- TextServicesDisplayAttributePropertyRanges.cs
- DesignTimeParseData.cs
- UserPreferenceChangingEventArgs.cs
- HandleCollector.cs
- TextBoxLine.cs
- StrongNameMembershipCondition.cs
- UdpDiscoveryMessageFilter.cs
- WebServiceErrorEvent.cs
- MetadataItem_Static.cs
- XmlSecureResolver.cs
- GenericTypeParameterConverter.cs
- TemplateBuilder.cs
- Int64Converter.cs
- ValueTable.cs
- UnsupportedPolicyOptionsException.cs
- CompilerGeneratedAttribute.cs
- BaseTemplateParser.cs
- RadioButton.cs
- UnsupportedPolicyOptionsException.cs
- BitmapDownload.cs
- HttpModule.cs
- Preprocessor.cs
- MediaPlayer.cs
- SQLDateTimeStorage.cs
- SafeSecurityHelper.cs
- ProfileEventArgs.cs
- Int32RectConverter.cs
- Classification.cs
- DecoderFallback.cs
- BufferedGraphicsContext.cs
- FileDialog_Vista_Interop.cs
- BuildProviderCollection.cs
- SelectionChangedEventArgs.cs
- ColorInterpolationModeValidation.cs
- XmlObjectSerializerReadContext.cs
- SoapEnvelopeProcessingElement.cs
- ClusterRegistryConfigurationProvider.cs
- HMACSHA256.cs
- GACMembershipCondition.cs
- ElementNotAvailableException.cs
- Root.cs
- OperationInvokerBehavior.cs
- UIElementAutomationPeer.cs
- PropertyDescriptorCollection.cs
- VisualTreeHelper.cs
- IndexedString.cs
- PointAnimationClockResource.cs
- XmlText.cs
- Visual3DCollection.cs
- EntityStoreSchemaFilterEntry.cs
- SqlBulkCopyColumnMappingCollection.cs
- DictionarySurrogate.cs
- CatalogPartDesigner.cs
- XmlEntity.cs
- FormViewDeleteEventArgs.cs
- NativeCompoundFileAPIs.cs
- Serializer.cs
- clipboard.cs