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
- Certificate.cs
- ExtentKey.cs
- DateTimeFormatInfo.cs
- SQLGuidStorage.cs
- AuthenticatedStream.cs
- ISessionStateStore.cs
- ExtendedPropertyCollection.cs
- BaseValidator.cs
- KeyConstraint.cs
- CorrelationQuery.cs
- securitymgrsite.cs
- MatcherBuilder.cs
- ZipIOLocalFileDataDescriptor.cs
- TagMapCollection.cs
- SolidColorBrush.cs
- FrameworkContentElement.cs
- SiteMapPath.cs
- XsdDuration.cs
- ObjectTag.cs
- DirectoryLocalQuery.cs
- DesignSurfaceServiceContainer.cs
- DeobfuscatingStream.cs
- SamlAuthorizationDecisionStatement.cs
- ColorAnimation.cs
- wgx_exports.cs
- Viewport3DAutomationPeer.cs
- XmlKeywords.cs
- BuildProvidersCompiler.cs
- RegexRunner.cs
- brushes.cs
- EventLogEntryCollection.cs
- ExpandSegmentCollection.cs
- AdornerPresentationContext.cs
- ExpressionEditor.cs
- ResolveNameEventArgs.cs
- OutOfProcStateClientManager.cs
- AbstractSvcMapFileLoader.cs
- EntityParameterCollection.cs
- RowVisual.cs
- XmlNavigatorStack.cs
- DataGridViewColumnStateChangedEventArgs.cs
- DateTimeFormatInfo.cs
- SqlFactory.cs
- NameValueCollection.cs
- ExeConfigurationFileMap.cs
- VisualTreeHelper.cs
- CompositeKey.cs
- SignedXmlDebugLog.cs
- MSG.cs
- SiteMapHierarchicalDataSourceView.cs
- StatusBar.cs
- cookieexception.cs
- DataTableNewRowEvent.cs
- CodeObjectCreateExpression.cs
- HtmlInputSubmit.cs
- _CommandStream.cs
- SafeRegistryHandle.cs
- SqlDataReader.cs
- CellTreeNodeVisitors.cs
- TraceRecord.cs
- DbTransaction.cs
- CancellationScope.cs
- PageContent.cs
- ElementProxy.cs
- HostedElements.cs
- SecurityCredentialsManager.cs
- UTF32Encoding.cs
- EmissiveMaterial.cs
- DictionaryTraceRecord.cs
- TraceHwndHost.cs
- ExponentialEase.cs
- FaultBookmark.cs
- RuntimeHandles.cs
- SplineKeyFrames.cs
- MembershipUser.cs
- ListBox.cs
- MetricEntry.cs
- DataControlLinkButton.cs
- RegexMatch.cs
- QueryableDataSource.cs
- InfiniteTimeSpanConverter.cs
- RevocationPoint.cs
- Nodes.cs
- SQLDouble.cs
- handlecollector.cs
- ExpressionBindings.cs
- CompositeActivityTypeDescriptorProvider.cs
- TreeView.cs
- _TimerThread.cs
- PenContext.cs
- MissingManifestResourceException.cs
- Trigger.cs
- FamilyMapCollection.cs
- PerformanceCounterManager.cs
- XmlSchemaValidator.cs
- EntityWrapperFactory.cs
- ThicknessAnimationBase.cs
- DataSourceCache.cs
- CleanUpVirtualizedItemEventArgs.cs
- FrameworkPropertyMetadata.cs