Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / CallbackValidator.cs / 1305376 / CallbackValidator.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 {
public sealed class CallbackValidator : ConfigurationValidatorBase {
Type _type;
ValidatorCallback _callback;
public CallbackValidator(Type type, ValidatorCallback callback) : this(callback) {
if (type == null) {
throw new ArgumentNullException("type");
}
_type = type;
}
// Do not check for null type here to handle the callback attribute case
internal CallbackValidator(ValidatorCallback callback) {
if (callback == null) {
throw new ArgumentNullException("callback");
}
_type = null;
_callback = callback;
}
public override bool CanValidate(Type type) {
return (type == _type || _type == null);
}
public override void Validate(object value) {
_callback(value);
}
}
}
// 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 {
public sealed class CallbackValidator : ConfigurationValidatorBase {
Type _type;
ValidatorCallback _callback;
public CallbackValidator(Type type, ValidatorCallback callback) : this(callback) {
if (type == null) {
throw new ArgumentNullException("type");
}
_type = type;
}
// Do not check for null type here to handle the callback attribute case
internal CallbackValidator(ValidatorCallback callback) {
if (callback == null) {
throw new ArgumentNullException("callback");
}
_type = null;
_callback = callback;
}
public override bool CanValidate(Type type) {
return (type == _type || _type == null);
}
public override void Validate(object value) {
_callback(value);
}
}
}
// 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
- LingerOption.cs
- TypeBuilderInstantiation.cs
- Animatable.cs
- TextEndOfParagraph.cs
- SqlInternalConnection.cs
- SoapReflectionImporter.cs
- ClientTargetCollection.cs
- ServiceSettingsResponseInfo.cs
- DropDownList.cs
- X500Name.cs
- OuterGlowBitmapEffect.cs
- SqlDataSourceConfigureSelectPanel.cs
- ControlPaint.cs
- ReceiveCompletedEventArgs.cs
- Size3DConverter.cs
- SettingsPropertyValueCollection.cs
- ModelItemCollectionImpl.cs
- SecuritySessionSecurityTokenProvider.cs
- BatchParser.cs
- GridViewRowEventArgs.cs
- CompositeDataBoundControl.cs
- DataSysAttribute.cs
- RegexCompilationInfo.cs
- RawStylusSystemGestureInputReport.cs
- TemplateModeChangedEventArgs.cs
- CacheRequest.cs
- ProjectedSlot.cs
- InstanceCreationEditor.cs
- Selector.cs
- PointValueSerializer.cs
- StreamInfo.cs
- XmlEntity.cs
- GridViewCancelEditEventArgs.cs
- ResXResourceReader.cs
- ReplyChannel.cs
- RequiredAttributeAttribute.cs
- DataGridViewCellStyle.cs
- oledbmetadatacolumnnames.cs
- InputChannelBinder.cs
- Interlocked.cs
- SystemColorTracker.cs
- XsdBuildProvider.cs
- DataGridItemEventArgs.cs
- MultiPageTextView.cs
- SpinLock.cs
- LocalIdCollection.cs
- AudioFileOut.cs
- ObjectKeyFrameCollection.cs
- PropertyMetadata.cs
- ParameterCollection.cs
- DiagnosticsElement.cs
- arabicshape.cs
- ApplicationGesture.cs
- URLString.cs
- QueryCursorEventArgs.cs
- ProtectedConfigurationSection.cs
- DataPager.cs
- IPEndPointCollection.cs
- ImageCodecInfoPrivate.cs
- TabPage.cs
- ResponseBodyWriter.cs
- SrgsElementList.cs
- DetailsViewCommandEventArgs.cs
- JsonObjectDataContract.cs
- DbInsertCommandTree.cs
- Helper.cs
- DataGridViewCellEventArgs.cs
- Transform.cs
- ComplexTypeEmitter.cs
- FontDifferentiator.cs
- Size.cs
- RootDesignerSerializerAttribute.cs
- UntrustedRecipientException.cs
- TextInfo.cs
- DataGridRow.cs
- LoadedOrUnloadedOperation.cs
- TransformGroup.cs
- BooleanProjectedSlot.cs
- DbMetaDataColumnNames.cs
- OleDbPropertySetGuid.cs
- CollectionViewProxy.cs
- ListCollectionView.cs
- WebCategoryAttribute.cs
- TextServicesDisplayAttributePropertyRanges.cs
- JsonDataContract.cs
- ModuleBuilderData.cs
- ObjectQuery.cs
- IOException.cs
- IntSecurity.cs
- SaveFileDialog.cs
- RangeBase.cs
- ProviderMetadataCachedInformation.cs
- WebServiceData.cs
- FileSystemWatcher.cs
- PlatformNotSupportedException.cs
- CipherData.cs
- FileDataSourceCache.cs
- Package.cs
- XmlComplianceUtil.cs
- SwitchLevelAttribute.cs