Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- OrthographicCamera.cs
- PolicyStatement.cs
- ExtendedProperty.cs
- Parser.cs
- __ComObject.cs
- WindowsButton.cs
- SqlNode.cs
- ButtonBaseAdapter.cs
- DateRangeEvent.cs
- GroupBoxAutomationPeer.cs
- CodeFieldReferenceExpression.cs
- PieceDirectory.cs
- CustomErrorCollection.cs
- MobileControlsSectionHandler.cs
- PriorityRange.cs
- TraceUtils.cs
- XmlJsonWriter.cs
- DataFormats.cs
- XPathDocumentIterator.cs
- SchemaElementDecl.cs
- SQLByte.cs
- SerialPinChanges.cs
- HttpEncoder.cs
- FormsIdentity.cs
- NameValueFileSectionHandler.cs
- ArrayTypeMismatchException.cs
- shaperfactoryquerycacheentry.cs
- Int32Converter.cs
- RelationshipConverter.cs
- DropDownHolder.cs
- ParserHooks.cs
- Size3D.cs
- Region.cs
- NullRuntimeConfig.cs
- WeakReadOnlyCollection.cs
- SecurityHelper.cs
- SerialReceived.cs
- RTTypeWrapper.cs
- MethodToken.cs
- wgx_exports.cs
- MaterializeFromAtom.cs
- relpropertyhelper.cs
- TypeReference.cs
- LambdaSerializationException.cs
- Tokenizer.cs
- ResourceDisplayNameAttribute.cs
- VisualState.cs
- Button.cs
- X509CertificateClaimSet.cs
- CodeDomSerializerBase.cs
- FastEncoderWindow.cs
- ColorTransformHelper.cs
- TCEAdapterGenerator.cs
- TextElement.cs
- GetWinFXPath.cs
- SkewTransform.cs
- VariantWrapper.cs
- ViewStateException.cs
- ScopelessEnumAttribute.cs
- TreeBuilderXamlTranslator.cs
- IPAddress.cs
- CodeGeneratorOptions.cs
- CharacterShapingProperties.cs
- JsonServiceDocumentSerializer.cs
- VirtualPathUtility.cs
- CompressionTransform.cs
- ReflectionPermission.cs
- SizeChangedInfo.cs
- Overlapped.cs
- BindingSource.cs
- SByteStorage.cs
- TraceInternal.cs
- DataGridState.cs
- StylusCollection.cs
- OptionUsage.cs
- UserMapPath.cs
- ArithmeticException.cs
- PropertyInformation.cs
- ExceptionUtil.cs
- HtmlLink.cs
- TokenDescriptor.cs
- MaskedTextProvider.cs
- GeneralTransform2DTo3D.cs
- DtrList.cs
- FormView.cs
- cookiecontainer.cs
- SynchronizedDispatch.cs
- BaseValidator.cs
- PTManager.cs
- XsltOutput.cs
- DirectoryInfo.cs
- DataBindingList.cs
- SQLMembershipProvider.cs
- TextFormatterImp.cs
- DropShadowEffect.cs
- CSharpCodeProvider.cs
- XomlCompilerParameters.cs
- ZoneButton.cs
- DataSourceCacheDurationConverter.cs
- WinInetCache.cs