optimizations
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.ComponentModel;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
@@ -672,13 +674,33 @@ public class RadValidationProviderEx : Component, ISupportInitialize, IExtenderP
|
||||
[Editor(DesignerConsts.RadValidationRuleEditorString, typeof(UITypeEditor))]
|
||||
public void SetValidationRule(RadControl control, FilterDescriptor rule)
|
||||
{
|
||||
var radValidationRule = rule as IRadValidationRuleEx;
|
||||
if (radValidationRule == null)
|
||||
if (rule is not IRadValidationRuleEx radValidationRule)
|
||||
RemoveControlFromRules(control);
|
||||
else
|
||||
{
|
||||
radValidationRule.AddControl(control);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Associates a validation rule with the specified RadControls descendant.</para>
|
||||
/// </summary>
|
||||
/// <param name="controls">A RadControl collection descendant that represents the editors.</param>
|
||||
/// <param name="rule">A RadValidationRule descendant that represents the validation rule.</param>
|
||||
[Editor(DesignerConsts.RadValidationRuleEditorString, typeof(UITypeEditor))]
|
||||
public void SetValidationRule(IEnumerable controls, FilterDescriptor rule)
|
||||
{
|
||||
SetValidationRule(controls.OfType<RadControl>(), rule);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Associates a validation rule with the specified RadControls descendant.</para>
|
||||
/// </summary>
|
||||
/// <param name="controls">A RadControl collection descendant that represents the editors.</param>
|
||||
/// <param name="rule">A RadValidationRule descendant that represents the validation rule.</param>
|
||||
[Editor(DesignerConsts.RadValidationRuleEditorString, typeof(UITypeEditor))]
|
||||
public void SetValidationRule(IEnumerable<RadControl> controls, FilterDescriptor rule)
|
||||
{
|
||||
foreach (var control in controls)
|
||||
SetValidationRule(control, rule);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user