Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Configuration / ConfigUtil.cs / 1305376 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DecodeHelper.cs
- RelationshipConverter.cs
- InstanceBehavior.cs
- PasswordPropertyTextAttribute.cs
- DataKey.cs
- HttpContext.cs
- CellConstant.cs
- StackBuilderSink.cs
- RewritingSimplifier.cs
- DecoderFallbackWithFailureFlag.cs
- Debug.cs
- COM2TypeInfoProcessor.cs
- UIElement3D.cs
- Substitution.cs
- HttpCacheVaryByContentEncodings.cs
- TransferMode.cs
- CodeIdentifiers.cs
- RelationshipType.cs
- ClientSettingsProvider.cs
- InfoCardTraceRecord.cs
- ContentControl.cs
- XmlNodeChangedEventArgs.cs
- ReadOnlyTernaryTree.cs
- HtmlAnchor.cs
- StreamWithDictionary.cs
- CqlErrorHelper.cs
- ToolStripSeparatorRenderEventArgs.cs
- GenericsInstances.cs
- AxisAngleRotation3D.cs
- SourceFilter.cs
- ProcessHost.cs
- XmlCharCheckingWriter.cs
- ReadOnlyHierarchicalDataSourceView.cs
- ConnectionManagementSection.cs
- RuleSet.cs
- SystemBrushes.cs
- InheritanceContextChangedEventManager.cs
- TextSerializer.cs
- TextCollapsingProperties.cs
- BoundConstants.cs
- XmlMapping.cs
- RadioButtonPopupAdapter.cs
- CriticalFinalizerObject.cs
- EncodingStreamWrapper.cs
- IUnknownConstantAttribute.cs
- NativeRightsManagementAPIsStructures.cs
- WriteTimeStream.cs
- XmlConverter.cs
- PenThreadPool.cs
- IgnoreFileBuildProvider.cs
- UTF8Encoding.cs
- TypeUsageBuilder.cs
- BufferedGraphicsContext.cs
- MailMessageEventArgs.cs
- NameSpaceEvent.cs
- X509UI.cs
- ModuleConfigurationInfo.cs
- Wizard.cs
- StorageTypeMapping.cs
- ReverseInheritProperty.cs
- ServiceOperationParameter.cs
- DeviceSpecificChoiceCollection.cs
- StylusPlugin.cs
- LayoutTableCell.cs
- AutomationElementIdentifiers.cs
- Constraint.cs
- _TLSstream.cs
- ThreadExceptionEvent.cs
- XmlBaseReader.cs
- NameObjectCollectionBase.cs
- Span.cs
- FreezableCollection.cs
- RowSpanVector.cs
- ConnectionStringSettings.cs
- RSACryptoServiceProvider.cs
- HMACSHA1.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- TrackingProfileManager.cs
- OracleEncoding.cs
- WebPartZone.cs
- SeekStoryboard.cs
- TransformPatternIdentifiers.cs
- HttpModuleAction.cs
- TemplateBamlTreeBuilder.cs
- IgnorePropertiesAttribute.cs
- DataGridViewLinkCell.cs
- ProgressPage.cs
- SafeNativeMethodsCLR.cs
- Types.cs
- WeakReadOnlyCollection.cs
- AuthStoreRoleProvider.cs
- BuildTopDownAttribute.cs
- TextElementAutomationPeer.cs
- PassportIdentity.cs
- DetailsViewUpdateEventArgs.cs
- ParameterBuilder.cs
- AttachedPropertyBrowsableAttribute.cs
- XmlSchemaAnnotation.cs
- XmlBindingWorker.cs
- WebReference.cs