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
- activationcontext.cs
- SeverityFilter.cs
- NetworkCredential.cs
- PackWebRequestFactory.cs
- _OSSOCK.cs
- RegexMatch.cs
- ToolStripHighContrastRenderer.cs
- ProcessInfo.cs
- FormParameter.cs
- XmlSchemaGroup.cs
- Buffer.cs
- SecurityBindingElement.cs
- QueryOutputWriter.cs
- RegexCaptureCollection.cs
- BCryptSafeHandles.cs
- FormsAuthentication.cs
- SqlComparer.cs
- ServiceX509SecurityTokenProvider.cs
- IssuedTokenServiceCredential.cs
- ServiceDescriptionSerializer.cs
- Positioning.cs
- ClientApiGenerator.cs
- TransactionState.cs
- MarkupWriter.cs
- DesignerLoader.cs
- ProxyWebPart.cs
- QueryOperationResponseOfT.cs
- MetadataItem.cs
- ConfigurationSectionCollection.cs
- SQLCharsStorage.cs
- PrinterSettings.cs
- SystemWebSectionGroup.cs
- FormatterServices.cs
- ObjectItemCollection.cs
- TopClause.cs
- DbDataAdapter.cs
- TemplateNameScope.cs
- SocketException.cs
- TypeElement.cs
- MissingManifestResourceException.cs
- TraceUtils.cs
- ExternalCalls.cs
- WorkflowInstanceQuery.cs
- TypeSystem.cs
- DefaultEventAttribute.cs
- SwitchAttribute.cs
- TreeNodeCollectionEditorDialog.cs
- DoubleLink.cs
- StatusBarDrawItemEvent.cs
- ArrayExtension.cs
- WindowsStatic.cs
- PathSegment.cs
- WebBrowserProgressChangedEventHandler.cs
- GlobalizationSection.cs
- CachedPathData.cs
- Block.cs
- AssemblyResourceLoader.cs
- SimplePropertyEntry.cs
- StoragePropertyMapping.cs
- CounterCreationDataCollection.cs
- Compiler.cs
- ClientSettingsSection.cs
- Polyline.cs
- MDIClient.cs
- ByteStream.cs
- PropertyPath.cs
- ControlAdapter.cs
- CmsInterop.cs
- BitmapEffectDrawing.cs
- DataGridViewLinkCell.cs
- ConfigXmlCDataSection.cs
- DesignerSerializationOptionsAttribute.cs
- WebBrowserNavigatedEventHandler.cs
- ModelUIElement3D.cs
- Application.cs
- WmlValidationSummaryAdapter.cs
- FixedSOMPageElement.cs
- CustomValidator.cs
- ToolStripContentPanelDesigner.cs
- Canvas.cs
- SmiEventSink.cs
- MessageHeader.cs
- Geometry.cs
- CqlBlock.cs
- WFItemsToSpacerVisibility.cs
- SystemIPAddressInformation.cs
- Int64.cs
- ComboBoxRenderer.cs
- TableLayoutPanelCellPosition.cs
- HttpListenerException.cs
- Pkcs7Recipient.cs
- DispatchChannelSink.cs
- MailWebEventProvider.cs
- MultiTrigger.cs
- TemplatePagerField.cs
- PreservationFileWriter.cs
- AuthenticationService.cs
- NumberFormatInfo.cs
- ProgressBar.cs
- StringConverter.cs