Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Configuration / System / Configuration / SubclassTypeValidator.cs / 1 / SubclassTypeValidator.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.IO; using System.Reflection; using System.Security.Permissions; using System.Xml; using System.Collections.Specialized; using System.Globalization; using System.ComponentModel; using System.Security; using System.Text; using System.Text.RegularExpressions; namespace System.Configuration { // This class validates that the value is a subclass of a specified type public sealed class SubclassTypeValidator : ConfigurationValidatorBase { private Type _base; public SubclassTypeValidator(Type baseClass) { if (baseClass == null) { throw new ArgumentNullException("baseClass"); } _base = baseClass; } public override bool CanValidate(Type type) { return (type == typeof(Type)); } public override void Validate(object value) { if (value == null) { return; } // Make a check here since value.GetType() returns RuntimeType rather then Type if (!(value is Type)) { ValidatorUtils.HelperParamValidation(value, typeof(Type)); } if (!_base.IsAssignableFrom((Type)value)) { throw new ArgumentException(SR.GetString(SR.Subclass_validator_error, ((Type)value).FullName, _base.FullName)); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.IO; using System.Reflection; using System.Security.Permissions; using System.Xml; using System.Collections.Specialized; using System.Globalization; using System.ComponentModel; using System.Security; using System.Text; using System.Text.RegularExpressions; namespace System.Configuration { // This class validates that the value is a subclass of a specified type public sealed class SubclassTypeValidator : ConfigurationValidatorBase { private Type _base; public SubclassTypeValidator(Type baseClass) { if (baseClass == null) { throw new ArgumentNullException("baseClass"); } _base = baseClass; } public override bool CanValidate(Type type) { return (type == typeof(Type)); } public override void Validate(object value) { if (value == null) { return; } // Make a check here since value.GetType() returns RuntimeType rather then Type if (!(value is Type)) { ValidatorUtils.HelperParamValidation(value, typeof(Type)); } if (!_base.IsAssignableFrom((Type)value)) { throw new ArgumentException(SR.GetString(SR.Subclass_validator_error, ((Type)value).FullName, _base.FullName)); } } } } // 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
- DbgUtil.cs
- DBSchemaTable.cs
- XmlSchemaAnnotated.cs
- RotateTransform3D.cs
- ThemeDirectoryCompiler.cs
- OutputScopeManager.cs
- Sql8ConformanceChecker.cs
- ThreadStateException.cs
- FacetDescriptionElement.cs
- AvTraceDetails.cs
- SiteMapNodeItemEventArgs.cs
- TimeSpanValidator.cs
- XmlSchemaSet.cs
- DocumentViewer.cs
- TextEndOfParagraph.cs
- srgsitem.cs
- Int32.cs
- ServiceMetadataExtension.cs
- SerializableAttribute.cs
- StateRuntime.cs
- ToolStripDropDownMenu.cs
- EventPropertyMap.cs
- WindowsNonControl.cs
- MessagePartSpecification.cs
- SqlConnectionPoolProviderInfo.cs
- ModelTypeConverter.cs
- ISO2022Encoding.cs
- ArrangedElement.cs
- HostedTcpTransportManager.cs
- GeometryCombineModeValidation.cs
- MatrixAnimationBase.cs
- FrameSecurityDescriptor.cs
- CachedFontFace.cs
- StyleXamlParser.cs
- UnderstoodHeaders.cs
- MetadataStore.cs
- IndentTextWriter.cs
- Transform.cs
- IndentedWriter.cs
- StringDictionary.cs
- DoubleAnimationUsingPath.cs
- QueryContinueDragEventArgs.cs
- SafeProcessHandle.cs
- Pair.cs
- TreeNodeBinding.cs
- HierarchicalDataBoundControl.cs
- uribuilder.cs
- ArrayWithOffset.cs
- WpfPayload.cs
- GetPageCompletedEventArgs.cs
- DockAndAnchorLayout.cs
- DateTimeUtil.cs
- SizeValueSerializer.cs
- LinqTreeNodeEvaluator.cs
- AttributeEmitter.cs
- FlowNode.cs
- DbDeleteCommandTree.cs
- ReflectTypeDescriptionProvider.cs
- RightsManagementUser.cs
- MobileListItemCollection.cs
- RequestStatusBarUpdateEventArgs.cs
- PropertyEntry.cs
- Item.cs
- Parser.cs
- HttpDictionary.cs
- DaylightTime.cs
- StringInfo.cs
- WorkflowWebHostingModule.cs
- ByteAnimationBase.cs
- ExpressionVisitor.cs
- SafeWaitHandle.cs
- Column.cs
- RoleGroupCollectionEditor.cs
- NonVisualControlAttribute.cs
- NativeObjectSecurity.cs
- CodeStatement.cs
- ThreadStartException.cs
- InteropAutomationProvider.cs
- StreamReader.cs
- ReadWriteControlDesigner.cs
- CodeNamespaceImportCollection.cs
- ListBoxAutomationPeer.cs
- DoubleLinkListEnumerator.cs
- MissingSatelliteAssemblyException.cs
- XmlNamespaceMappingCollection.cs
- Int32CollectionValueSerializer.cs
- ConditionalDesigner.cs
- ExtensionFile.cs
- InfoCardCryptoHelper.cs
- XmlSchemaImport.cs
- SafeSecurityHandles.cs
- EditorZoneBase.cs
- InternalsVisibleToAttribute.cs
- xsdvalidator.cs
- PageClientProxyGenerator.cs
- SourceLineInfo.cs
- QilGenerator.cs
- Gdiplus.cs
- KeyFrames.cs
- EpmCustomContentWriterNodeData.cs