/// <summary> /// Creates a synchronized (thread-safe) wrapper for a /// <c>ValidatorCollection</c> instance. /// </summary> /// <returns> /// An <c>ValidatorCollection</c> wrapper that is synchronized (thread-safe). /// </returns> public static ValidatorCollection Synchronized(ValidatorCollection list) { if (list == null) { throw new ArgumentNullException("list"); } return(new SyncValidatorCollection(list)); }
/// <summary> /// Creates a read-only wrapper for a /// <c>ValidatorCollection</c> instance. /// </summary> /// <returns> /// An <c>ValidatorCollection</c> wrapper that is read-only. /// </returns> public static ValidatorCollection ReadOnly(ValidatorCollection list) { if (list == null) { throw new ArgumentNullException("list"); } return(new ReadOnlyValidatorCollection(list)); }
/// <summary> /// Creates a shallow copy of the <see cref="ValidatorCollection"/>. /// </summary> public virtual object Clone() { ValidatorCollection newColl = new ValidatorCollection(m_count); Array.Copy(m_array, 0, newColl.m_array, 0, m_count); newColl.m_count = m_count; newColl.m_version = m_version; return(newColl); }
/// <summary> /// Adds the elements of another <c>ValidatorCollection</c> to the current <c>ValidatorCollection</c>. /// </summary> /// <param name="x">The <c>ValidatorCollection</c> whose elements should be added to the end of the current <c>ValidatorCollection</c>.</param> /// <returns>The new <see cref="ValidatorCollection.Count"/> of the <c>ValidatorCollection</c>.</returns> public virtual int AddRange(ValidatorCollection x) { if (m_count + x.Count >= m_array.Length) { EnsureCapacity(m_count + x.Count); } Array.Copy(x.m_array, 0, m_array, m_count, x.Count); m_count += x.Count; m_version++; return(m_count); }
public static void DeRegister(BaseValidator validator, Form hostingForm) { // Remove this validator from the list of registered validators ValidatorCollection validators = (ValidatorCollection)_validators[hostingForm]; validators.Remove(validator); // Remove form bucket if all validators on the form are de-registered if (validators.Count == 0) { _validators.Remove(hostingForm); } }
// TODO: //private static Dictionary<Form, ValidatorCollection> validators = new Dictionary<Form, ValidatorCollection>(); public static void Register(BaseValidator validator, Form hostingForm) { // Create form bucket if it doesn't exist if (_validators[hostingForm] == null) { _validators[hostingForm] = new ValidatorCollection(); } // Add this validator to the list of registered validators ValidatorCollection validators = (ValidatorCollection)_validators[hostingForm]; validators.Add(validator); }
public void Validate() { // Validate all validators on this form, ensuring first invalid // control (in tab order) is selected Control firstInTabOrder = null; ValidatorCollection validators = ValidatorManager.GetValidators(_hostingForm); if (null == validators) { return; } foreach (BaseValidator validator in validators) { // Validate control validator.Validate(); // Record tab order if before current recorded tab order if (!validator.IsValid) { if ((firstInTabOrder == null) || (firstInTabOrder.TabIndex > validator.ControlToValidate.TabIndex)) { firstInTabOrder = validator.ControlToValidate; } } } // Select first invalid control in tab order, if any if (firstInTabOrder != null) { firstInTabOrder.Focus(); if (firstInTabOrder is TextBoxBase) { TextBoxBase textbox = firstInTabOrder as TextBoxBase; textbox.SelectionStart = 0; textbox.SelectionLength = textbox.Text.Length; } } }
public override int AddRange(ValidatorCollection x) { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
internal ReadOnlyValidatorCollection(ValidatorCollection list) { m_collection = list; }
public override int AddRange(ValidatorCollection x) { lock (this.m_root) return(m_collection.AddRange(x)); }
internal SyncValidatorCollection(ValidatorCollection list) { m_root = list.SyncRoot; m_collection = list; }
/// <summary> /// Initializes a new instance of the <c>Enumerator</c> class. /// </summary> /// <param name="tc"></param> internal Enumerator(ValidatorCollection tc) { m_collection = tc; m_index = -1; m_version = tc.m_version; }
/// <summary> /// Initializes a new instance of the <c>ValidatorCollection</c> class /// that contains elements copied from the specified <c>ValidatorCollection</c>. /// </summary> /// <param name="c">The <c>ValidatorCollection</c> whose elements are copied to the new collection.</param> public ValidatorCollection(ValidatorCollection c) { m_array = new BaseValidator[c.Count]; AddRange(c); }