Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / RegexStringValidator.cs / 1305376 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UIPermission.cs
- TextureBrush.cs
- DataView.cs
- BuilderInfo.cs
- ComboBox.cs
- VisualStates.cs
- StringValidator.cs
- BinaryObjectWriter.cs
- IconBitmapDecoder.cs
- EraserBehavior.cs
- RemotingConfiguration.cs
- NotFiniteNumberException.cs
- XmlElementList.cs
- InstallerTypeAttribute.cs
- CollectionsUtil.cs
- SerializationInfoEnumerator.cs
- WebPartCollection.cs
- StickyNoteHelper.cs
- Msmq4SubqueuePoisonHandler.cs
- Rotation3DAnimationBase.cs
- ConfigurationSettings.cs
- Renderer.cs
- Validator.cs
- WebGetAttribute.cs
- Literal.cs
- DataTableCollection.cs
- HttpCapabilitiesBase.cs
- OdbcCommandBuilder.cs
- AssociationEndMember.cs
- _ProxyChain.cs
- ActiveXContainer.cs
- Int64Storage.cs
- Message.cs
- HitTestWithGeometryDrawingContextWalker.cs
- ThumbButtonInfoCollection.cs
- ServiceDescriptions.cs
- AutoResizedEvent.cs
- FrugalList.cs
- DocumentViewerBaseAutomationPeer.cs
- AttributedMetaModel.cs
- XmlComment.cs
- RewritingProcessor.cs
- ValueSerializer.cs
- DnsPermission.cs
- WorkflowTraceTransfer.cs
- ParseHttpDate.cs
- ActiveXSerializer.cs
- XhtmlCssHandler.cs
- MediaScriptCommandRoutedEventArgs.cs
- ConfigsHelper.cs
- XmlSchemaCompilationSettings.cs
- UnsafeNetInfoNativeMethods.cs
- Interlocked.cs
- LockCookie.cs
- ResetableIterator.cs
- ObjectConverter.cs
- RangeBase.cs
- Helpers.cs
- WsdlBuildProvider.cs
- DescendentsWalkerBase.cs
- DataPager.cs
- CleanUpVirtualizedItemEventArgs.cs
- FlowchartDesignerCommands.cs
- AnnotationObservableCollection.cs
- DataGridViewComboBoxCell.cs
- GeneralTransform.cs
- HttpClientCertificate.cs
- TypeContext.cs
- MessageSmuggler.cs
- UnsafeNativeMethodsTablet.cs
- MemberNameValidator.cs
- TextTreeExtractElementUndoUnit.cs
- TargetParameterCountException.cs
- ListControlConvertEventArgs.cs
- XmlElementCollection.cs
- LocationReferenceEnvironment.cs
- ClaimComparer.cs
- LiteralTextParser.cs
- WindowsAuthenticationEventArgs.cs
- DataGridViewRowHeaderCell.cs
- CallContext.cs
- MappingException.cs
- ExpressionBuilderCollection.cs
- HelpProvider.cs
- SortDescriptionCollection.cs
- WeakEventTable.cs
- FloaterParaClient.cs
- ToolstripProfessionalRenderer.cs
- TemplateControlBuildProvider.cs
- EmbeddedMailObject.cs
- SystemResourceKey.cs
- DataGridViewCheckBoxColumn.cs
- ProviderConnectionPoint.cs
- CatalogZoneBase.cs
- SynthesizerStateChangedEventArgs.cs
- ILGen.cs
- UpdateExpressionVisitor.cs
- TypeReference.cs
- ResourceProperty.cs
- BinaryParser.cs