public BuildQueryDialog([NotNull] string query, CustomValidationType type) { Assert.ArgumentNotNull(query, nameof(query)); InitializeComponent(); this.InitializeDialog(); Loaded += ControlLoaded; Text = query; Type = type; if (type == CustomValidationType.ExpandedWebConfig || type == CustomValidationType.WebConfig) { DatabasePanel.Visibility = Visibility.Collapsed; } else { SitePanel.Visibility = Visibility.Collapsed; } DatabaseUri = DatabaseSelector.DatabaseUri; DatabaseSelector.SelectionChanged += SetDatabaseUri; SiteSelector.SelectionChanged += SetSite; }
private static string GetExpression(CustomValidationType customValidationType) { switch (customValidationType) { case CustomValidationType.Alphanumeric: return("^[a-z]([-a-z0-9]*[a-z0-9])?$"); case CustomValidationType.Fqdn: return("(^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$)"); case CustomValidationType.Email: return("(^[a-zA-Z0-9]([-_.@a-zA-Z0-9]*[a-zA-Z0-9])?$)"); default: throw new ArgumentException($"Unknown valication type {customValidationType}"); } }
public CustomValidationExpressionConfiguration(CustomValidationType validationType, string expression) { this.ValidationType = validationType; this.Expression = expression; }
/// <summary> /// 半角英数字(とハイフンなど)のみを許可する入力規則 /// </summary> public CustomValidationAttribute(CustomValidationType customValidationType, [CallerMemberName] string propertyName = null) : base(GetExpression(customValidationType)) { this.PropertyName = propertyName; this.CustomValidationType = customValidationType; ErrorMessage = $"'{propertyName}' {GetErrorMessage()}"; }