Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / fx / src / xsp / System / Web / Configuration / ConfigUtil.cs / 2 / ConfigUtil.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System; using System.Threading; using System.Configuration; using System.Xml; using System.Web.Compilation; using System.Web.Util; internal class ConfigUtil { private ConfigUtil() { } internal static void CheckBaseType(Type expectedBaseType, Type userBaseType, string propertyName, ConfigurationElement configElement) { // Make sure the base type is valid if (!expectedBaseType.IsAssignableFrom(userBaseType)) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_type_to_inherit_from, userBaseType.FullName, expectedBaseType.FullName), configElement.ElementInformation.Properties[propertyName].Source, configElement.ElementInformation.Properties[propertyName].LineNumber); } } internal static Type GetType(string typeName, string propertyName, ConfigurationElement configElement, XmlNode node, bool checkAptcaBit, bool ignoreCase) { // We should get either a propertyName/configElement or node, but not both. // They are used only for error reporting. Debug.Assert((propertyName != null) != (node != null)); Type val; try { val = BuildManager.GetType(typeName, true /*throwOnError*/, ignoreCase); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (node != null) { throw new ConfigurationErrorsException(e.Message, e, node); } else { if (configElement != null) { throw new ConfigurationErrorsException(e.Message, e, configElement.ElementInformation.Properties[propertyName].Source, configElement.ElementInformation.Properties[propertyName].LineNumber); } else { throw new ConfigurationErrorsException(e.Message, e); } } } // If we're not in full trust, only allow types that have the APTCA bit (ASURT 139687), // unless the checkAptcaBit flag is false if (checkAptcaBit) { if (node != null) { HttpRuntime.FailIfNoAPTCABit(val, node); } else { HttpRuntime.FailIfNoAPTCABit(val, configElement != null ? configElement.ElementInformation : null, propertyName); } } return val; } internal static Type GetType(string typeName, string propertyName, ConfigurationElement configElement) { return GetType(typeName, propertyName, configElement, true /*checkAptcaBit*/); } internal static Type GetType(string typeName, string propertyName, ConfigurationElement configElement, bool checkAptcaBit) { return GetType(typeName, propertyName, configElement, checkAptcaBit, false); } internal static Type GetType(string typeName, string propertyName, ConfigurationElement configElement, bool checkAptcaBit, bool ignoreCase) { return GetType(typeName, propertyName, configElement, null /*node*/, checkAptcaBit, ignoreCase); } internal static Type GetType(string typeName, XmlNode node) { return GetType(typeName, node, false /*ignoreCase*/); } internal static Type GetType(string typeName, XmlNode node, bool ignoreCase) { return GetType(typeName, null, null, node, true /*checkAptcaBit*/, ignoreCase); } internal static void CheckAssignableType(Type baseType, Type type, ConfigurationElement configElement, string propertyName) { if (!baseType.IsAssignableFrom(type)) { throw new ConfigurationErrorsException( SR.GetString(SR.Type_doesnt_inherit_from_type, type.FullName, baseType.FullName), configElement.ElementInformation.Properties[propertyName].Source, configElement.ElementInformation.Properties[propertyName].LineNumber); } } internal static void CheckAssignableType(Type baseType, Type baseType2, Type type, ConfigurationElement configElement, string propertyName) { if (!baseType.IsAssignableFrom(type) && !baseType2.IsAssignableFrom(type)) { throw new ConfigurationErrorsException( SR.GetString(SR.Type_doesnt_inherit_from_type, type.FullName, baseType.FullName), configElement.ElementInformation.Properties[propertyName].Source, configElement.ElementInformation.Properties[propertyName].LineNumber); } } internal static bool IsTypeHandlerOrFactory(Type t) { return typeof(IHttpHandler).IsAssignableFrom(t) || typeof(IHttpHandlerFactory).IsAssignableFrom(t); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebConfigurationFileMap.cs
- SerializationAttributes.cs
- TogglePattern.cs
- Deflater.cs
- ElementNotEnabledException.cs
- BoolExpr.cs
- mda.cs
- ButtonBaseAdapter.cs
- ScaleTransform3D.cs
- sqlnorm.cs
- PathFigureCollectionValueSerializer.cs
- GetPageCompletedEventArgs.cs
- ScrollEvent.cs
- BuildTopDownAttribute.cs
- DocumentGridContextMenu.cs
- DateTimeStorage.cs
- UTF8Encoding.cs
- ServiceOperationParameter.cs
- ObjectStorage.cs
- SqlProvider.cs
- IODescriptionAttribute.cs
- FormatVersion.cs
- ScrollData.cs
- ServiceOperationParameter.cs
- TrustSection.cs
- FixedSOMContainer.cs
- PassportPrincipal.cs
- CounterSetInstance.cs
- RotateTransform3D.cs
- PropertyManager.cs
- WebPartDescriptionCollection.cs
- WSTransactionSection.cs
- DataGridHeaderBorder.cs
- FlowLayoutPanel.cs
- ControlDesigner.cs
- DynamicPropertyReader.cs
- AsyncStreamReader.cs
- BuilderInfo.cs
- DeviceContext2.cs
- Attachment.cs
- LinkUtilities.cs
- InternalTypeHelper.cs
- InitializerFacet.cs
- GenericUriParser.cs
- RtfControlWordInfo.cs
- NullableDecimalAverageAggregationOperator.cs
- AutomationPropertyInfo.cs
- ConfigurationSettings.cs
- RangeValidator.cs
- MultipartIdentifier.cs
- ButtonStandardAdapter.cs
- FeatureSupport.cs
- PolicyManager.cs
- IgnoreSectionHandler.cs
- Identifier.cs
- ProcessThreadCollection.cs
- DecimalConstantAttribute.cs
- ObjectDataSourceDesigner.cs
- RootNamespaceAttribute.cs
- PlatformCulture.cs
- Timeline.cs
- Timer.cs
- ExpressionParser.cs
- TextEndOfSegment.cs
- TemplateInstanceAttribute.cs
- ProviderConnectionPointCollection.cs
- BindingMAnagerBase.cs
- ToolStripContentPanelRenderEventArgs.cs
- PageHandlerFactory.cs
- EventData.cs
- TimeManager.cs
- SecurityMode.cs
- ThreadPool.cs
- KeySplineConverter.cs
- FlowDocumentReader.cs
- Point3DAnimationUsingKeyFrames.cs
- CreateSequence.cs
- SmiConnection.cs
- PlaceHolder.cs
- DataServiceConfiguration.cs
- Constraint.cs
- MessageQueue.cs
- TextContainerChangeEventArgs.cs
- XmlSchemaCompilationSettings.cs
- DrawingContextDrawingContextWalker.cs
- XmlSortKey.cs
- AnnotationHighlightLayer.cs
- UIElement3DAutomationPeer.cs
- TriggerAction.cs
- Attributes.cs
- TreeNodeStyle.cs
- SafeFileMapViewHandle.cs
- Select.cs
- ComplexPropertyEntry.cs
- ImageInfo.cs
- FileDataSource.cs
- dsa.cs
- NominalTypeEliminator.cs
- SchemaImporterExtensionsSection.cs
- ToolStripItem.cs