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
- PersonalizationState.cs
- ConstructorBuilder.cs
- SortAction.cs
- Popup.cs
- FormsAuthenticationModule.cs
- ToolStripLocationCancelEventArgs.cs
- ToolStripDropDownClosingEventArgs.cs
- BinaryObjectWriter.cs
- DefaultDiscoveryServiceExtension.cs
- NonSerializedAttribute.cs
- ImageCodecInfoPrivate.cs
- Page.cs
- SchemaType.cs
- ValidationSummary.cs
- NotFiniteNumberException.cs
- CheckBoxPopupAdapter.cs
- QueryCacheManager.cs
- ResolveDuplex11AsyncResult.cs
- SQLGuidStorage.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- AuthenticationModuleElement.cs
- MiniMapControl.xaml.cs
- FontClient.cs
- MemberCollection.cs
- ReplacementText.cs
- Model3DGroup.cs
- WeakEventTable.cs
- cookieexception.cs
- RootBuilder.cs
- EventPrivateKey.cs
- OleDbSchemaGuid.cs
- DrawingImage.cs
- CssTextWriter.cs
- ResumeStoryboard.cs
- CloudCollection.cs
- SystemException.cs
- ReadOnlyDictionary.cs
- WebPartManagerInternals.cs
- ProfileSection.cs
- JournalEntryStack.cs
- DatagramAdapter.cs
- WebPartEditorOkVerb.cs
- PreviewPrintController.cs
- XPathArrayIterator.cs
- XmlQueryStaticData.cs
- SelectionItemProviderWrapper.cs
- ConfigPathUtility.cs
- NGCSerializerAsync.cs
- CodeTypeReference.cs
- WebPartZone.cs
- UrlMappingsModule.cs
- StringResourceManager.cs
- DelegateTypeInfo.cs
- TableParaClient.cs
- ExternalException.cs
- DataSourceXmlClassAttribute.cs
- WebPartHeaderCloseVerb.cs
- ServiceOperationParameter.cs
- ComponentResourceKeyConverter.cs
- CompleteWizardStep.cs
- PropertyEmitter.cs
- ControlParser.cs
- ImageMetadata.cs
- PartitionResolver.cs
- SqlDuplicator.cs
- SQLBytes.cs
- OutputScope.cs
- SecUtil.cs
- StateValidator.cs
- Clock.cs
- TextWriterEngine.cs
- RuleConditionDialog.cs
- ResourceProperty.cs
- NetworkCredential.cs
- DbException.cs
- DataBindingList.cs
- EmptyStringExpandableObjectConverter.cs
- GenericXmlSecurityToken.cs
- FullTextLine.cs
- TransactionScope.cs
- CodeDirectiveCollection.cs
- SyncMethodInvoker.cs
- DynamicDataResources.Designer.cs
- HttpConfigurationContext.cs
- ImageKeyConverter.cs
- ProcessThreadCollection.cs
- DataGridViewColumn.cs
- StrokeNodeOperations.cs
- EditCommandColumn.cs
- HttpConfigurationSystem.cs
- _FixedSizeReader.cs
- DiscoveryClientReferences.cs
- GeneralTransform2DTo3D.cs
- FunctionImportElement.cs
- SqlDataRecord.cs
- MaskedTextBox.cs
- SimpleLine.cs
- ZeroOpNode.cs
- VoiceSynthesis.cs
- HttpCachePolicyBase.cs