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
- CellParaClient.cs
- HwndSubclass.cs
- SqlIdentifier.cs
- TypedDataSetSchemaImporterExtensionFx35.cs
- XPathDocumentNavigator.cs
- NetStream.cs
- ConsoleTraceListener.cs
- DbParameterHelper.cs
- XdrBuilder.cs
- DataListItem.cs
- GestureRecognizer.cs
- GridViewCommandEventArgs.cs
- CharacterShapingProperties.cs
- DnsCache.cs
- CalendarDateRangeChangingEventArgs.cs
- Transform.cs
- BitmapEncoder.cs
- _LoggingObject.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- ObjectConverter.cs
- ActivitiesCollection.cs
- RectAnimation.cs
- ButtonRenderer.cs
- HashJoinQueryOperatorEnumerator.cs
- UInt64Converter.cs
- DocumentPageViewAutomationPeer.cs
- WindowsFormsSectionHandler.cs
- ProgressPage.cs
- WindowsRichEdit.cs
- DesignerTransaction.cs
- Switch.cs
- ReliableMessagingVersionConverter.cs
- GlyphsSerializer.cs
- DataRowCollection.cs
- WasAdminWrapper.cs
- DataColumnSelectionConverter.cs
- CacheEntry.cs
- AuthenticationModulesSection.cs
- StylusPointPropertyInfoDefaults.cs
- ChangeBlockUndoRecord.cs
- ContainerParagraph.cs
- PassportAuthentication.cs
- UIElement3D.cs
- Html32TextWriter.cs
- Package.cs
- ISAPIRuntime.cs
- BezierSegment.cs
- ClientScriptItemCollection.cs
- Schema.cs
- BrushConverter.cs
- XmlSerializer.cs
- ElementMarkupObject.cs
- SqlDataSourceEnumerator.cs
- CellTreeNodeVisitors.cs
- ControlUtil.cs
- HiddenFieldPageStatePersister.cs
- DynamicObject.cs
- ToolStrip.cs
- DataControlButton.cs
- RankException.cs
- OracleLob.cs
- ClientBuildManagerCallback.cs
- WindowsEditBoxRange.cs
- OrthographicCamera.cs
- AutoGeneratedField.cs
- EdmSchemaAttribute.cs
- StateManagedCollection.cs
- NonSerializedAttribute.cs
- querybuilder.cs
- OciHandle.cs
- CompositeDataBoundControl.cs
- CodeDirectiveCollection.cs
- AnnotationElement.cs
- OrElse.cs
- ComponentCommands.cs
- InstanceHandleReference.cs
- ServiceReference.cs
- MenuItem.cs
- ImageAutomationPeer.cs
- MimePart.cs
- Grid.cs
- FontDriver.cs
- DataGridHelper.cs
- BamlResourceSerializer.cs
- SynchronizedInputAdaptor.cs
- Parser.cs
- VariableAction.cs
- RawStylusSystemGestureInputReport.cs
- Slider.cs
- XhtmlBasicImageAdapter.cs
- XmlCompatibilityReader.cs
- GeneralTransformGroup.cs
- ItemDragEvent.cs
- IsolatedStorageException.cs
- sqlinternaltransaction.cs
- WebResourceAttribute.cs
- AssemblyResourceLoader.cs
- cookiecontainer.cs
- TypeConverterAttribute.cs
- DataServiceQueryContinuation.cs