Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- _Events.cs
- HashJoinQueryOperatorEnumerator.cs
- FontResourceCache.cs
- MultitargetingHelpers.cs
- ValueType.cs
- _LocalDataStoreMgr.cs
- CryptographicAttribute.cs
- CodeEventReferenceExpression.cs
- CompositeCollectionView.cs
- CircleEase.cs
- FrameworkObject.cs
- ColorAnimation.cs
- SQLInt64Storage.cs
- CodeDomSerializerException.cs
- Grid.cs
- SmtpReplyReaderFactory.cs
- EventLogQuery.cs
- GridItemPattern.cs
- EncoderParameters.cs
- StylusPointPropertyInfoDefaults.cs
- PolygonHotSpot.cs
- ComponentEvent.cs
- Help.cs
- lengthconverter.cs
- ScriptMethodAttribute.cs
- Authorization.cs
- PassportPrincipal.cs
- EndpointDesigner.cs
- CrossSiteScriptingValidation.cs
- ListSourceHelper.cs
- XmlSerializerNamespaces.cs
- RemotingClientProxy.cs
- WebServiceMethodData.cs
- StringCollection.cs
- WizardSideBarListControlItem.cs
- Stack.cs
- InternalRelationshipCollection.cs
- VisualBasicImportReference.cs
- ParameterBuilder.cs
- CommandID.cs
- SystemPens.cs
- CacheMode.cs
- SqlAggregateChecker.cs
- Compiler.cs
- HttpModulesSection.cs
- ResXFileRef.cs
- SpellerHighlightLayer.cs
- ViewBox.cs
- assemblycache.cs
- RepeaterItem.cs
- BaseResourcesBuildProvider.cs
- DbSourceCommand.cs
- DelegatingConfigHost.cs
- HelpKeywordAttribute.cs
- GifBitmapDecoder.cs
- PropertyValueChangedEvent.cs
- VectorConverter.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- HwndStylusInputProvider.cs
- AppDomainEvidenceFactory.cs
- FtpWebRequest.cs
- VectorCollectionValueSerializer.cs
- GeneralTransform3DGroup.cs
- DelegateCompletionCallbackWrapper.cs
- UnknownWrapper.cs
- BindingCollection.cs
- ProviderSettingsCollection.cs
- HttpProfileGroupBase.cs
- CheckoutException.cs
- ExpressionEvaluator.cs
- KeyFrames.cs
- GlobalizationAssembly.cs
- ExpressionBuilder.cs
- TextServicesLoader.cs
- DefaultValueAttribute.cs
- LexicalChunk.cs
- ProfilePropertyNameValidator.cs
- TraceUtility.cs
- WindowsProgressbar.cs
- ZipIOFileItemStream.cs
- WebServicesInteroperability.cs
- ImageAttributes.cs
- ReturnType.cs
- CachedFontFamily.cs
- CellRelation.cs
- RtfToXamlReader.cs
- InkCollectionBehavior.cs
- ECDiffieHellmanCng.cs
- HtmlInputPassword.cs
- ProcessHostConfigUtils.cs
- WebPartConnectionsConnectVerb.cs
- FixedSOMPageElement.cs
- BinHexDecoder.cs
- HitTestFilterBehavior.cs
- GlobalProxySelection.cs
- AspNetRouteServiceHttpHandler.cs
- BaseTemplateParser.cs
- MaskedTextBox.cs
- GACIdentityPermission.cs
- SqlBuffer.cs