Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Configuration / System / Configuration / RegexStringValidator.cs / 1 / RegexStringValidator.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 class RegexStringValidator : ConfigurationValidatorBase { private string _expression; private Regex _regex; public RegexStringValidator(string regex) { if (string.IsNullOrEmpty(regex)) { throw ExceptionUtil.ParameterNullOrEmpty("regex"); } _expression = regex; _regex = new Regex(regex, RegexOptions.Compiled); } public override bool CanValidate(Type type) { return (type == typeof(string)); } public override void Validate(object value) { ValidatorUtils.HelperParamValidation(value, typeof(string)); if (value == null) { return; } Match match = _regex.Match((string)value); if (!match.Success) { throw new ArgumentException(SR.GetString(SR.Regex_validator_error, _expression)); } } } } // 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 class RegexStringValidator : ConfigurationValidatorBase { private string _expression; private Regex _regex; public RegexStringValidator(string regex) { if (string.IsNullOrEmpty(regex)) { throw ExceptionUtil.ParameterNullOrEmpty("regex"); } _expression = regex; _regex = new Regex(regex, RegexOptions.Compiled); } public override bool CanValidate(Type type) { return (type == typeof(string)); } public override void Validate(object value) { ValidatorUtils.HelperParamValidation(value, typeof(string)); if (value == null) { return; } Match match = _regex.Match((string)value); if (!match.Success) { throw new ArgumentException(SR.GetString(SR.Regex_validator_error, _expression)); } } } } // 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
- WebPartDisplayModeCancelEventArgs.cs
- WSSecurityPolicy11.cs
- PenThreadPool.cs
- LinkButton.cs
- XmlSerializationWriter.cs
- DataGridTablesFactory.cs
- ResourceContainer.cs
- ProviderConnectionPointCollection.cs
- IEnumerable.cs
- VBIdentifierDesigner.xaml.cs
- Comparer.cs
- TextEffect.cs
- Token.cs
- FileBasedResourceGroveler.cs
- TrackBarDesigner.cs
- IntranetCredentialPolicy.cs
- BackStopAuthenticationModule.cs
- URLString.cs
- ProviderUtil.cs
- NavigatorOutput.cs
- StreamingContext.cs
- SchemaImporterExtensionElement.cs
- HtmlInputRadioButton.cs
- TabControlEvent.cs
- LoginCancelEventArgs.cs
- ControlIdConverter.cs
- DynamicRendererThreadManager.cs
- LayoutEvent.cs
- RelatedCurrencyManager.cs
- ObjectViewQueryResultData.cs
- DefaultTextStore.cs
- DataTableMapping.cs
- AnnotationHelper.cs
- TypeSemantics.cs
- PointF.cs
- HttpModuleCollection.cs
- OSFeature.cs
- PageSettings.cs
- ScrollChrome.cs
- WindowHideOrCloseTracker.cs
- TrustLevel.cs
- FamilyTypefaceCollection.cs
- ParameterCollection.cs
- SmiEventSink_DeferedProcessing.cs
- DbConnectionPool.cs
- XsltSettings.cs
- CollectionType.cs
- ContainerVisual.cs
- UserControlAutomationPeer.cs
- XmlBinaryReader.cs
- MetadataCache.cs
- TabPage.cs
- TextTreeText.cs
- HttpHandlerAction.cs
- MimeParameters.cs
- ControlBuilderAttribute.cs
- MarkupExtensionParser.cs
- NativeMethods.cs
- FontStyle.cs
- UpdateManifestForBrowserApplication.cs
- XmlSchemaSimpleContent.cs
- PieceDirectory.cs
- IDReferencePropertyAttribute.cs
- PointIndependentAnimationStorage.cs
- Assert.cs
- ActivityExecutor.cs
- Roles.cs
- Size3D.cs
- ExceptionUtil.cs
- ResourcesChangeInfo.cs
- HorizontalAlignConverter.cs
- SqlDataSourceConfigureSortForm.cs
- RuntimeWrappedException.cs
- ToolboxItemCollection.cs
- ControlCachePolicy.cs
- Exceptions.cs
- CallbackException.cs
- CodeVariableDeclarationStatement.cs
- __Error.cs
- ExternalFile.cs
- ScriptModule.cs
- COM2PictureConverter.cs
- FamilyMapCollection.cs
- GenericWebPart.cs
- DocumentSequenceHighlightLayer.cs
- EventTrigger.cs
- LoginCancelEventArgs.cs
- querybuilder.cs
- GcHandle.cs
- DropShadowEffect.cs
- RepeatButtonAutomationPeer.cs
- SpecialNameAttribute.cs
- SmiEventSink_Default.cs
- FeatureManager.cs
- UserControlAutomationPeer.cs
- FileDetails.cs
- SignatureResourcePool.cs
- DBNull.cs
- GroupDescription.cs
- UnmanagedBitmapWrapper.cs