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
- XhtmlBasicImageAdapter.cs
- RadioButtonStandardAdapter.cs
- FontResourceCache.cs
- ZoneLinkButton.cs
- IgnoreSectionHandler.cs
- XmlSchemaImporter.cs
- HiddenField.cs
- OleDbFactory.cs
- ItemCheckedEvent.cs
- RadioButton.cs
- OdbcCommandBuilder.cs
- DynamicValueConverter.cs
- DataColumn.cs
- ProfileSettingsCollection.cs
- TreeViewCancelEvent.cs
- CurrentChangingEventArgs.cs
- ApplicationServiceManager.cs
- CodeExpressionStatement.cs
- DataGridSortCommandEventArgs.cs
- Geometry.cs
- SymmetricAlgorithm.cs
- AutomationPatternInfo.cs
- TemplateBuilder.cs
- ConfigurationManagerHelper.cs
- XmlCDATASection.cs
- ConditionedDesigner.cs
- SuspendDesigner.cs
- StdRegProviderWrapper.cs
- DataContractJsonSerializer.cs
- InsufficientMemoryException.cs
- sitestring.cs
- CompModHelpers.cs
- _AutoWebProxyScriptEngine.cs
- KeyValuePairs.cs
- PreservationFileReader.cs
- LinearGradientBrush.cs
- Cell.cs
- WebPartConnectionsConfigureVerb.cs
- CodeCatchClause.cs
- Translator.cs
- CheckBoxRenderer.cs
- PageSetupDialog.cs
- CompilationUnit.cs
- ClientScriptManager.cs
- PowerModeChangedEventArgs.cs
- DataSourceHelper.cs
- XmlFormatReaderGenerator.cs
- ReliabilityContractAttribute.cs
- ProfileSection.cs
- DataGridViewRowsAddedEventArgs.cs
- ParseElement.cs
- IriParsingElement.cs
- SqlServer2KCompatibilityAnnotation.cs
- SpellerStatusTable.cs
- ListBoxItem.cs
- AppDomainFactory.cs
- ScriptResourceAttribute.cs
- XPathDocumentNavigator.cs
- MarkupWriter.cs
- ApplicationSecurityManager.cs
- TaskExtensions.cs
- ComponentCollection.cs
- serverconfig.cs
- DirectionalLight.cs
- CodeSubDirectoriesCollection.cs
- Material.cs
- SqlLiftWhereClauses.cs
- ComponentCommands.cs
- XmlUtil.cs
- SpecularMaterial.cs
- Hashtable.cs
- MinimizableAttributeTypeConverter.cs
- PenCursorManager.cs
- CodeSnippetTypeMember.cs
- WebControlsSection.cs
- ColumnHeaderConverter.cs
- EncodingTable.cs
- ThreadExceptionEvent.cs
- SmiEventSink.cs
- DataGridViewCellStyle.cs
- PrimarySelectionAdorner.cs
- SortFieldComparer.cs
- ShapeTypeface.cs
- SrgsRulesCollection.cs
- BuildProviderAppliesToAttribute.cs
- TaskDesigner.cs
- WebDisplayNameAttribute.cs
- Thumb.cs
- Schema.cs
- XmlDsigSep2000.cs
- RecognizeCompletedEventArgs.cs
- OrderedDictionary.cs
- SevenBitStream.cs
- SystemDropShadowChrome.cs
- XmlEventCache.cs
- ObjectItemAttributeAssemblyLoader.cs
- AlternateViewCollection.cs
- GifBitmapEncoder.cs
- ConnectionManagementSection.cs
- FontFamily.cs