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
- BrowserCapabilitiesFactoryBase.cs
- RoleServiceManager.cs
- DataGridrowEditEndingEventArgs.cs
- Run.cs
- BlockUIContainer.cs
- SqlReorderer.cs
- URLAttribute.cs
- FontDifferentiator.cs
- XmlSchemaInfo.cs
- RemotingServices.cs
- HttpApplication.cs
- ManualResetEvent.cs
- DataKey.cs
- Parser.cs
- OdbcErrorCollection.cs
- MenuItem.cs
- TableLayoutCellPaintEventArgs.cs
- XMLSchema.cs
- ValidatingReaderNodeData.cs
- PrinterUnitConvert.cs
- TreeNodeBindingCollection.cs
- Int64.cs
- ParseHttpDate.cs
- Attachment.cs
- TypefaceMetricsCache.cs
- TrustManagerMoreInformation.cs
- TextTreeInsertElementUndoUnit.cs
- SystemException.cs
- DesignerDataSchemaClass.cs
- BidOverLoads.cs
- ContentHostHelper.cs
- StandardRuntimeEnumValidatorAttribute.cs
- XPathException.cs
- TreeWalkHelper.cs
- WeakReferenceEnumerator.cs
- Expressions.cs
- Ipv6Element.cs
- PropertyIdentifier.cs
- SafeFindHandle.cs
- EditorZoneBase.cs
- PassportAuthenticationEventArgs.cs
- UrlAuthFailedErrorFormatter.cs
- ApplicationManager.cs
- RayMeshGeometry3DHitTestResult.cs
- DefaultEventAttribute.cs
- TextBlockAutomationPeer.cs
- sqlpipe.cs
- WindowsListViewItem.cs
- PropertyDescriptor.cs
- PeerCollaborationPermission.cs
- EndpointAddress.cs
- PeerNameRegistration.cs
- HitTestParameters.cs
- SimpleApplicationHost.cs
- Table.cs
- Table.cs
- LinqDataSourceContextData.cs
- UTF32Encoding.cs
- PreProcessor.cs
- PagerSettings.cs
- EntitySqlException.cs
- _WinHttpWebProxyDataBuilder.cs
- RSAOAEPKeyExchangeDeformatter.cs
- TextRunCache.cs
- HScrollProperties.cs
- IODescriptionAttribute.cs
- DbModificationClause.cs
- HttpWebRequest.cs
- SynchronizedDisposablePool.cs
- CollaborationHelperFunctions.cs
- ConfigurationException.cs
- RewritingValidator.cs
- HitTestParameters.cs
- RoutedCommand.cs
- SplitterCancelEvent.cs
- ContentHostHelper.cs
- QueryStringHandler.cs
- UrlPropertyAttribute.cs
- IntPtr.cs
- UnitySerializationHolder.cs
- ContextMenu.cs
- QilNode.cs
- WebPartDisplayMode.cs
- ExtenderControl.cs
- EncoderFallback.cs
- DataObjectSettingDataEventArgs.cs
- NetworkCredential.cs
- RelatedEnd.cs
- TransactionTraceIdentifier.cs
- ModifierKeysValueSerializer.cs
- StatusBarItemAutomationPeer.cs
- PropertyGroupDescription.cs
- FileVersion.cs
- XmlBindingWorker.cs
- EmptyEnumerable.cs
- Crc32.cs
- SynchronizationContext.cs
- ProviderCollection.cs
- MatrixTransform.cs
- XmlILConstructAnalyzer.cs