/// <summary> /// Binds <see cref="IColumns"/> to <see cref="ValidationPlaceholder"/>. /// </summary> /// <param name="source">The source <see cref="IColumns"/>.</param> /// <param name="bindings">The bindings to determine whether the <see cref="ValidationPlaceholder"/> is active.</param> /// <returns>The row binding object.</returns> public static RowBinding <ValidationPlaceholder> BindToValidationPlaceholder(this IColumns source, params RowBinding[] bindings) { source.VerifyNotNull(nameof(source)); source = source.Seal(); var result = new RowBinding <ValidationPlaceholder>(onSetup: (v, p) => { if (bindings != null && bindings.Length > 0) { var containingElements = new UIElement[bindings.Length]; for (int i = 0; i < containingElements.Length; i++) { containingElements[i] = bindings[i].GetSettingUpElement(); } v.Setup(containingElements); } }, onRefresh: null, onCleanup: (v, p) => { v.Cleanup(); }); var input = result.BeginInput(new ValueChangedTrigger <ValidationPlaceholder>(source, result)); foreach (var column in source) { input.WithFlush(column, (r, v) => true); } return(input.EndInput()); }
/// <summary>Determines whether the current columns and the specified columns contain the same elements.</summary> /// <param name="source">The current columns.</param> /// <param name="other">The columns to compare to the current columns.</param> /// <returns><see langword="true"/> if the current set and the specified columns contain the same elements; otherwise, <see langword="false" />.</returns> public static bool SetEquals(this IColumns source, IColumns other) { source.VerifyNotNull(nameof(source)); other.VerifyNotNull(nameof(other)); return(source.Count == other.Count ? source.ContainsAll(other) : false); }
/// <summary>Ensures set contain only elements that are present either in the current columns or in the specified columns, but not both.</summary> /// <param name="source">The current columns.</param> /// <param name="other">The columns to compare to the current columns.</param> /// <returns>A new set if there is any modification to current sealed set; otherwise, the current set.</returns> public static IColumns SymmetricExcept(this IColumns source, IColumns other) { source.VerifyNotNull(nameof(source)); other.VerifyNotNull(nameof(other)); IColumns removedColumnSet = Columns.Empty; foreach (var column in source) { if (other.Contains(column)) { removedColumnSet = removedColumnSet.Add(column); source = source.Remove(column); } } foreach (var column in other) { if (removedColumnSet.Contains(column)) { source = source.Add(column); } } return(source); }
/// <summary>Determines whether the current columns is a superset of a specified columns.</summary> /// <param name="source">The current columns.</param> /// <param name="other">The columns to compare to the current columns.</param> /// <returns><see langword="true"/> if the current set is a superset of the specified collection; otherwise, <see langword="false" />.</returns> public static bool IsSupersetOf(this IColumns source, IColumns other) { source.VerifyNotNull(nameof(source)); other.VerifyNotNull(nameof(other)); return(source.Count >= other.Count ? source.ContainsAll(other) : false); }
/// <summary>Determines whether the current columns is a proper (strict) subset of the specified columns.</summary> /// <param name="source">The current columns.</param> /// <param name="other">The columns to compare to the current columns.</param> /// <returns><see langword="true"/> if the current set is a proper subset of the specified collection; otherwise, <see langword="false" />.</returns> public static bool IsProperSubsetOf(this IColumns source, IColumns other) { source.VerifyNotNull(nameof(source)); other.VerifyNotNull(nameof(other)); return(source.Count < other.Count ? other.ContainsAll(source) : false); }
/// <summary>Ensures set contain all elements that are present in either the current columns or in the specified columns.</summary> /// <param name="source">The current columns.</param> /// <param name="other">The collection to add elements from.</param> /// <returns>A new set if there is any modification to current set and current set sealed; otherwise, the current set.</returns> public static IColumns Union(this IColumns source, IColumns other) { source.VerifyNotNull(nameof(source)); other.VerifyNotNull(nameof(other)); foreach (var column in other) { source = source.Add(column); } return(source); }
/// <summary>Determines whether the current columns overlaps with the specified columns.</summary> /// <param name="source">The current columns.</param> /// <param name="other">The columns to compare to the current columns.</param> /// <returns><see langword="true"/> if the current set overlaps with the specified columns; otherwise, <see langword="false" />.</returns> public static bool Overlaps(this IColumns source, IColumns other) { source.VerifyNotNull(nameof(source)); other.VerifyNotNull(nameof(other)); foreach (var column in source) { if (other.Contains(column)) { return(true); } } return(false); }
/// <summary>Removes the columns to ensure the set contains only columns both exist in the current columns and the specified columns.</summary> /// <param name="source">The current columns.</param> /// <param name="other">The columns to compare to the current columns.</param> /// <returns>A new set of columns if there is any modification to current sealed set; otherwise, the current set.</returns> public static IColumns Intersect(this IColumns source, IColumns other) { source.VerifyNotNull(nameof(source)); other.VerifyNotNull(nameof(other)); foreach (var column in source) { if (!other.Contains(column)) { source = source.Remove(column); } } return(source); }
/// <summary> /// Initializes a new instance of <see cref="ValueChangedEventArgs"/>. /// </summary> /// <param name="dataRow">The DataRow.</param> /// <param name="columns">The columns.</param> public ValueChangedEventArgs(DataRow dataRow, IColumns columns) : base(dataRow) { columns.VerifyNotNull(nameof(columns)); _columns = columns; }
/// <summary> /// Initializes a new instance of <see cref="ValueChangedTrigger{T}"/> class. /// </summary> /// <param name="columns">The columns.</param> /// <param name="rowBinding">The row binding.</param> public ValueChangedTrigger(IColumns columns, RowBinding <T> rowBinding) { _columns = columns.VerifyNotNull(nameof(columns)); _rowBinding = rowBinding.VerifyNotNull(nameof(rowBinding)); }