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
- __Error.cs
- FontResourceCache.cs
- ColumnMap.cs
- SID.cs
- CodeTryCatchFinallyStatement.cs
- BamlTreeUpdater.cs
- NavigatorOutput.cs
- X509Utils.cs
- ContainerAction.cs
- ValueExpressions.cs
- SqlCachedBuffer.cs
- StorageComplexPropertyMapping.cs
- ResourceProviderFactory.cs
- XmlQualifiedName.cs
- SoundPlayerAction.cs
- ChangeBlockUndoRecord.cs
- ServiceManagerHandle.cs
- SQLGuidStorage.cs
- DesignerTransaction.cs
- AuthorizationRuleCollection.cs
- DataRow.cs
- TranslateTransform.cs
- SchemaMerger.cs
- CorruptingExceptionCommon.cs
- LongTypeConverter.cs
- HostingEnvironmentSection.cs
- DataDocumentXPathNavigator.cs
- GridViewCancelEditEventArgs.cs
- MobileCapabilities.cs
- NativeRecognizer.cs
- XPathEmptyIterator.cs
- FormViewUpdateEventArgs.cs
- Model3DGroup.cs
- XmlSchemaSimpleContent.cs
- BinaryMessageEncodingBindingElement.cs
- ParseChildrenAsPropertiesAttribute.cs
- SqlTypeSystemProvider.cs
- SerializationHelper.cs
- CacheChildrenQuery.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- GacUtil.cs
- SingleTagSectionHandler.cs
- TreeView.cs
- RelationshipType.cs
- Int32RectConverter.cs
- RadioButtonPopupAdapter.cs
- XmlChildEnumerator.cs
- AddressingVersion.cs
- ExportOptions.cs
- StylusCollection.cs
- SimpleHandlerBuildProvider.cs
- IResourceProvider.cs
- Function.cs
- AssemblyBuilder.cs
- DataSourceDesigner.cs
- DiscoveryClientBindingElement.cs
- MessageCredentialType.cs
- InstanceLockQueryResult.cs
- ProxyGenerationError.cs
- DataRelationCollection.cs
- QilDataSource.cs
- FormatVersion.cs
- ObjectToIdCache.cs
- HtmlInputPassword.cs
- MemoryRecordBuffer.cs
- ping.cs
- ColumnResult.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- Button.cs
- ShaderRenderModeValidation.cs
- DbConnectionHelper.cs
- PageTheme.cs
- IdentityManager.cs
- __Filters.cs
- counter.cs
- DbConvert.cs
- ThemeDictionaryExtension.cs
- JulianCalendar.cs
- Rect.cs
- complextypematerializer.cs
- ConnectionStringSettingsCollection.cs
- Margins.cs
- FullTrustAssembliesSection.cs
- FragmentQueryProcessor.cs
- RotateTransform3D.cs
- PropertyInformationCollection.cs
- PeerObject.cs
- AttachedPropertyInfo.cs
- TextAdaptor.cs
- DataGridViewCellCancelEventArgs.cs
- DefaultParameterValueAttribute.cs
- PkcsUtils.cs
- NetNamedPipeSecurity.cs
- TrimSurroundingWhitespaceAttribute.cs
- SimpleNameService.cs
- SelectionProviderWrapper.cs
- DbParameterCollectionHelper.cs
- EntityDataSourceContextCreatingEventArgs.cs
- SizeChangedEventArgs.cs
- DiffuseMaterial.cs