Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / Configuration / HandlerFactoryCache.cs / 2 / HandlerFactoryCache.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * Config related classes for HttpApplication */ namespace System.Web.Configuration { using System; using System.Configuration; using System.Web.Compilation; /* * An object to cache a factory */ internal class HandlerFactoryCache { private IHttpHandlerFactory _factory; internal HandlerFactoryCache(string type) { Object instance = Create(type); // make sure it is either handler or handler factory if (instance is IHttpHandler) { // create bogus factory around it _factory = new HandlerFactoryWrapper((IHttpHandler)instance, GetHandlerType(type)); } else if (instance is IHttpHandlerFactory) { _factory = (IHttpHandlerFactory)instance; } else { throw new HttpException(SR.GetString(SR.Type_not_factory_or_handler, instance.GetType().FullName)); } } internal HandlerFactoryCache(HttpHandlerAction mapping) { Object instance = mapping.Create(); // make sure it is either handler or handler factory if (instance is IHttpHandler) { // create bogus factory around it _factory = new HandlerFactoryWrapper((IHttpHandler)instance, GetHandlerType(mapping)); } else if (instance is IHttpHandlerFactory) { _factory = (IHttpHandlerFactory)instance; } else { throw new HttpException(SR.GetString(SR.Type_not_factory_or_handler, instance.GetType().FullName)); } } internal IHttpHandlerFactory Factory { get { return _factory; } } internal Type GetHandlerType( HttpHandlerAction handlerAction ) { // HACKHACK: for now, let uncreatable types through and error later (for .soap factory) // This design should change - developers will want to know immediately // when they misspell a type Type t = BuildManager.GetType(handlerAction.Type, true /*throwOnFail*/, false /*ignoreCase*/); // throw for bad types in deferred case if (!ConfigUtil.IsTypeHandlerOrFactory(t)) throw new ConfigurationErrorsException(SR.GetString(SR.Type_not_factory_or_handler, handlerAction.Type), handlerAction.ElementInformation.Source, handlerAction.ElementInformation.LineNumber); return t; } internal Type GetHandlerType(string type) { // HACKHACK: for now, let uncreatable types through and error later (for .soap factory) // This design should change - developers will want to know immediately // when they misspell a type Type t = BuildManager.GetType(type, true /*throwOnFail*/, false /*ignoreCase*/); HttpRuntime.FailIfNoAPTCABit(t, null, null); // throw for bad types in deferred case if (!ConfigUtil.IsTypeHandlerOrFactory(t)) throw new ConfigurationErrorsException(SR.GetString(SR.Type_not_factory_or_handler, type)); return t; } internal object Create(string type) { // HACKHACK: for now, let uncreatable types through and error later (for .soap factory) // This design should change - developers will want to know immediately // when they misspell a type return HttpRuntime.CreateNonPublicInstance(GetHandlerType(type)); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SubpageParagraph.cs
- TraceSource.cs
- Token.cs
- ExpressionCopier.cs
- XmlSchemaAny.cs
- DynamicFilter.cs
- SoapExtensionReflector.cs
- GenericAuthenticationEventArgs.cs
- XmlCharCheckingWriter.cs
- TdsEnums.cs
- GrowingArray.cs
- _NegotiateClient.cs
- CodeAttachEventStatement.cs
- AdornerPresentationContext.cs
- EventMappingSettingsCollection.cs
- SecurityUniqueId.cs
- CompilerGlobalScopeAttribute.cs
- PackUriHelper.cs
- QuaternionIndependentAnimationStorage.cs
- OracleBoolean.cs
- LayoutEvent.cs
- Color.cs
- PropertyHelper.cs
- CommentAction.cs
- CredentialCache.cs
- TableProvider.cs
- ContentIterators.cs
- StorageConditionPropertyMapping.cs
- ResourceBinder.cs
- ByteKeyFrameCollection.cs
- EFAssociationProvider.cs
- DataGridCell.cs
- KeyGesture.cs
- DocumentApplicationState.cs
- WebControlToolBoxItem.cs
- MetadataFile.cs
- XamlBrushSerializer.cs
- LinkUtilities.cs
- IndependentAnimationStorage.cs
- DropDownButton.cs
- SettingsBindableAttribute.cs
- UserControl.cs
- DispatchWrapper.cs
- AssemblyAssociatedContentFileAttribute.cs
- XmlQueryCardinality.cs
- ThrowHelper.cs
- RecordBuilder.cs
- CodeFieldReferenceExpression.cs
- ScrollBarRenderer.cs
- IssuedTokenClientBehaviorsElementCollection.cs
- IArgumentProvider.cs
- ConfigurationManager.cs
- SiteMapDesignerDataSourceView.cs
- SingleSelectRootGridEntry.cs
- ViewEventArgs.cs
- PrePrepareMethodAttribute.cs
- URI.cs
- TextServicesContext.cs
- ListViewGroupCollectionEditor.cs
- AuthorizationSection.cs
- Int64AnimationBase.cs
- MessageRpc.cs
- InputScope.cs
- XmlWellformedWriterHelpers.cs
- StrongNameKeyPair.cs
- NetworkStream.cs
- SimpleExpression.cs
- TemplateBindingExtension.cs
- TemplateBindingExpressionConverter.cs
- Errors.cs
- InvalidMessageContractException.cs
- ExpressionList.cs
- SafeCancelMibChangeNotify.cs
- ReflectionHelper.cs
- BasicExpandProvider.cs
- COM2Enum.cs
- XmlSerializableServices.cs
- SiteIdentityPermission.cs
- TypeBuilder.cs
- StandardToolWindows.cs
- WebBrowserEvent.cs
- TextRunTypographyProperties.cs
- TimelineCollection.cs
- XamlFigureLengthSerializer.cs
- BinaryUtilClasses.cs
- TokenBasedSet.cs
- WindowInteropHelper.cs
- DispatcherExceptionEventArgs.cs
- DbReferenceCollection.cs
- EncoderFallback.cs
- BamlCollectionHolder.cs
- AuthenticatedStream.cs
- HighContrastHelper.cs
- DrawingAttributesDefaultValueFactory.cs
- SqlFacetAttribute.cs
- ExtendedPropertyInfo.cs
- ReversePositionQuery.cs
- ColorInterpolationModeValidation.cs
- Constant.cs
- CurrentTimeZone.cs