Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- XPathSelectionIterator.cs
- CheckPair.cs
- ISAPIWorkerRequest.cs
- TextDecorationCollectionConverter.cs
- MethodCallConverter.cs
- DetailsViewUpdatedEventArgs.cs
- BufferedGraphics.cs
- TransformGroup.cs
- RadioButton.cs
- StringAttributeCollection.cs
- InputScopeManager.cs
- TrackingQueryElement.cs
- DocumentPage.cs
- ServiceParser.cs
- XmlnsDictionary.cs
- FlowPosition.cs
- XPathNavigator.cs
- WebEvents.cs
- LongValidatorAttribute.cs
- ObjectRef.cs
- DriveNotFoundException.cs
- SingleAnimationUsingKeyFrames.cs
- ColorTransformHelper.cs
- MenuDesigner.cs
- SubMenuStyle.cs
- DelayDesigner.cs
- DoubleLink.cs
- OdbcEnvironmentHandle.cs
- XmlHierarchyData.cs
- IgnoreDeviceFilterElementCollection.cs
- ModifierKeysValueSerializer.cs
- cookiecollection.cs
- MessagePartSpecification.cs
- SafeHandle.cs
- QueryAsyncResult.cs
- XsltSettings.cs
- PKCS1MaskGenerationMethod.cs
- TakeOrSkipQueryOperator.cs
- TextBoxRenderer.cs
- EncoderExceptionFallback.cs
- StorageModelBuildProvider.cs
- ElementProxy.cs
- SystemUdpStatistics.cs
- HttpRawResponse.cs
- AutomationPatternInfo.cs
- PropertyTabChangedEvent.cs
- SystemIPAddressInformation.cs
- SystemNetHelpers.cs
- DataGridViewComboBoxEditingControl.cs
- StreamingContext.cs
- QilCloneVisitor.cs
- NumericUpDown.cs
- GroupLabel.cs
- XamlStyleSerializer.cs
- UInt32Storage.cs
- CharEnumerator.cs
- NavigationCommands.cs
- XmlEnumAttribute.cs
- ReflectTypeDescriptionProvider.cs
- ItemType.cs
- UnaryNode.cs
- XPathNavigatorKeyComparer.cs
- FolderBrowserDialogDesigner.cs
- StandardCommandToolStripMenuItem.cs
- PropertyToken.cs
- MessageContractImporter.cs
- OptimalBreakSession.cs
- XmlTextEncoder.cs
- _RequestCacheProtocol.cs
- FlowchartDesigner.Helpers.cs
- SpellerHighlightLayer.cs
- Thumb.cs
- QueryExecutionOption.cs
- safex509handles.cs
- ToolStripGripRenderEventArgs.cs
- LogArchiveSnapshot.cs
- PenLineCapValidation.cs
- ToolStripTextBox.cs
- CodeAttributeDeclaration.cs
- WarningException.cs
- Stackframe.cs
- Group.cs
- DataSourceControl.cs
- ParseNumbers.cs
- TypeUtil.cs
- WebPartVerbsEventArgs.cs
- ProjectionCamera.cs
- HttpCacheVaryByContentEncodings.cs
- HttpClientProtocol.cs
- Debug.cs
- GacUtil.cs
- CompositeControl.cs
- FlowDocumentReader.cs
- RSAPKCS1KeyExchangeFormatter.cs
- ThaiBuddhistCalendar.cs
- BuildProvidersCompiler.cs
- TextRangeSerialization.cs
- UIElementCollection.cs
- XmlCharCheckingWriter.cs
- WebAdminConfigurationHelper.cs