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
- CellParaClient.cs
- HttpContext.cs
- DispatcherObject.cs
- ApplicationServiceManager.cs
- GestureRecognizer.cs
- MatrixKeyFrameCollection.cs
- ObjectFullSpanRewriter.cs
- xmlfixedPageInfo.cs
- HashMembershipCondition.cs
- DataControlHelper.cs
- CodeEventReferenceExpression.cs
- InputDevice.cs
- AuthenticodeSignatureInformation.cs
- EntityViewGenerationConstants.cs
- InheritanceContextHelper.cs
- ReflectEventDescriptor.cs
- CaseInsensitiveHashCodeProvider.cs
- SafeLocalMemHandle.cs
- FormatterConverter.cs
- OraclePermission.cs
- ParseChildrenAsPropertiesAttribute.cs
- Camera.cs
- FormsAuthenticationModule.cs
- StylusSystemGestureEventArgs.cs
- TransformerInfo.cs
- OutputCacheSettingsSection.cs
- TryExpression.cs
- EFAssociationProvider.cs
- ExpressionVisitorHelpers.cs
- BufferedGraphics.cs
- ComplusEndpointConfigContainer.cs
- DispatchWrapper.cs
- HorizontalAlignConverter.cs
- Privilege.cs
- MsmqOutputMessage.cs
- DateTimeConverter2.cs
- BStrWrapper.cs
- Int64KeyFrameCollection.cs
- DrawingAttributes.cs
- ConstructorArgumentAttribute.cs
- SiteMapDesignerDataSourceView.cs
- PolygonHotSpot.cs
- SpecularMaterial.cs
- ProcessModule.cs
- VisualStyleRenderer.cs
- PropVariant.cs
- Int32Rect.cs
- ContentPlaceHolder.cs
- PeerInvitationResponse.cs
- SettingsProviderCollection.cs
- DataControlPagerLinkButton.cs
- ColumnMapVisitor.cs
- OperationContext.cs
- ResourceIDHelper.cs
- HttpGetClientProtocol.cs
- DataRowIndexBuffer.cs
- WebPartTracker.cs
- RequestQueue.cs
- MetadataArtifactLoaderFile.cs
- QualifiedCellIdBoolean.cs
- AssemblyCache.cs
- OLEDB_Util.cs
- HasRunnableWorkflowEvent.cs
- TreeNodeStyleCollection.cs
- ComplexType.cs
- TextRange.cs
- QilPatternVisitor.cs
- Enumerable.cs
- LabelLiteral.cs
- QueryOutputWriter.cs
- CloseSequence.cs
- PermissionRequestEvidence.cs
- PenContext.cs
- CorrelationService.cs
- ErrorEventArgs.cs
- DataViewSetting.cs
- StrongNameUtility.cs
- ISO2022Encoding.cs
- NullableBoolConverter.cs
- Menu.cs
- CodeArgumentReferenceExpression.cs
- NativeCppClassAttribute.cs
- PeerTransportListenAddressValidatorAttribute.cs
- StoreAnnotationsMap.cs
- TextFormatterImp.cs
- CodeTypeParameterCollection.cs
- Quaternion.cs
- QilStrConcatenator.cs
- Descriptor.cs
- SafeArchiveContext.cs
- DataSourceCollectionBase.cs
- DefaultValueAttribute.cs
- TextFormatterContext.cs
- ObjectIDGenerator.cs
- DataBoundControlHelper.cs
- CommonGetThemePartSize.cs
- XmlChildEnumerator.cs
- InkCanvasSelection.cs
- HashHelper.cs
- DictionarySectionHandler.cs