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
- Match.cs
- HyperLinkField.cs
- EdmPropertyAttribute.cs
- DataBoundControlHelper.cs
- BindUriHelper.cs
- ItemPager.cs
- IndicShape.cs
- OutgoingWebResponseContext.cs
- Serialization.cs
- ServiceOperationDetailViewControl.cs
- SqlInternalConnectionTds.cs
- TextFormatter.cs
- ToolBar.cs
- GenericEnumerator.cs
- _SSPISessionCache.cs
- Helpers.cs
- ECDiffieHellman.cs
- JavascriptCallbackMessageInspector.cs
- MonthChangedEventArgs.cs
- DesignTableCollection.cs
- Schema.cs
- OperatingSystem.cs
- LassoHelper.cs
- VScrollBar.cs
- TemplatePagerField.cs
- NamespaceMapping.cs
- ListCollectionView.cs
- SQLStringStorage.cs
- ScrollBarAutomationPeer.cs
- MaskedTextBoxDesigner.cs
- SecurityContextKeyIdentifierClause.cs
- WindowsProgressbar.cs
- Listbox.cs
- BaseCodePageEncoding.cs
- PhysicalAddress.cs
- DataGridViewElement.cs
- CodeVariableReferenceExpression.cs
- ConfigurationValues.cs
- XmlUnspecifiedAttribute.cs
- BuildProviderAppliesToAttribute.cs
- Int16Storage.cs
- TriggerBase.cs
- SignatureTargetIdManager.cs
- MenuItemBindingCollection.cs
- DataGridRowClipboardEventArgs.cs
- Site.cs
- DesignerAutoFormatStyle.cs
- ContainsRowNumberChecker.cs
- FontStretch.cs
- TextElementEnumerator.cs
- shaperfactoryquerycacheentry.cs
- AutoResizedEvent.cs
- MetafileHeader.cs
- ObjectListItem.cs
- wgx_exports.cs
- FormsAuthenticationUser.cs
- ContextMenuService.cs
- ClientSettingsStore.cs
- Error.cs
- ServiceHostingEnvironment.cs
- Border.cs
- AssociationTypeEmitter.cs
- documentation.cs
- SecurityElement.cs
- WmpBitmapDecoder.cs
- TextEndOfLine.cs
- ParseHttpDate.cs
- Compiler.cs
- ExeConfigurationFileMap.cs
- XmlTypeAttribute.cs
- XmlArrayAttribute.cs
- RemoteAsymmetricSignatureFormatter.cs
- DecoderExceptionFallback.cs
- ListParagraph.cs
- TextSegment.cs
- DesignerTransaction.cs
- HitTestResult.cs
- StrongNameUtility.cs
- keycontainerpermission.cs
- Flattener.cs
- SplitterPanel.cs
- DoubleStorage.cs
- ComboBoxItem.cs
- XmlSignificantWhitespace.cs
- PrivateFontCollection.cs
- TableRow.cs
- PixelShader.cs
- HeaderedContentControl.cs
- OleAutBinder.cs
- BrowserTree.cs
- StorageEndPropertyMapping.cs
- SplitContainer.cs
- SplitterCancelEvent.cs
- RemotingSurrogateSelector.cs
- ConnectionInterfaceCollection.cs
- Exceptions.cs
- _BaseOverlappedAsyncResult.cs
- TypeFieldSchema.cs
- AsymmetricKeyExchangeDeformatter.cs
- DbConnectionFactory.cs