public IScalars Add(Scalar value) { value.VerifyNotNull(nameof(value)); if (Contains(value)) { return(this); } if (!IsSealed) { _hashSet.Add(value); return(this); } if (Count == 0) { return(value); } else { var result = new HashSetScalars(); foreach (var column in this) { result.Add(column); } result.Add(value); return(result); } }
/// <summary> /// Binds a scalar data to <see cref="ComboBox"/>. /// </summary> /// <typeparam name="T">The data type of the column.</typeparam> /// <param name="source">The source scalar data.</param> /// <param name="dropDownList">Data of drop-down list.</param> /// <param name="selectedValuePath">The path that is used to get the selected value from drop-down list.</param> /// <param name="displayMemberPath">The path to serve as the visual representation of the drop-down list item.</param> /// <returns>The scalar binding object.</returns> public static ScalarBinding <ComboBox> BindToComboBox <T>(this Scalar <T> source, Scalar <IEnumerable> dropDownList, string selectedValuePath = "Value", string displayMemberPath = "Display") { source.VerifyNotNull(nameof(source)); dropDownList.VerifyNotNull(nameof(dropDownList)); if (string.IsNullOrEmpty(selectedValuePath)) { throw new ArgumentNullException(nameof(selectedValuePath)); } if (string.IsNullOrEmpty(displayMemberPath)) { throw new ArgumentNullException(nameof(displayMemberPath)); } return(new ScalarBinding <ComboBox>( onSetup: (v, p) => { v.SelectedValuePath = selectedValuePath; v.DisplayMemberPath = displayMemberPath; }, onRefresh: (v, p) => { v.ItemsSource = dropDownList.Value; v.SelectedValue = source.GetValue(); }, onCleanup: (v, p) => { v.ItemsSource = null; v.SelectedValuePath = null; v.DisplayMemberPath = null; }).WithInput(ComboBox.SelectedValueProperty, source, e => (T)e.SelectedValue)); }
/// <summary> /// Setup the flushing operation. /// </summary> /// <param name="scalar">The scalar data.</param> /// <param name="flush">The delegate to flush input.</param> /// <returns>This scalar input for fluent coding.</returns> public ScalarInput <T> WithFlush(Scalar scalar, Func <T, bool> flush) { scalar.VerifyNotNull(nameof(scalar)); flush.VerifyNotNull(nameof(flush)); VerifyNotSealed(); _target = _target.Union(scalar); _flushFuncs.Add(flush); return(this); }
public IScalars Remove(Scalar value) { value.VerifyNotNull(nameof(value)); if (!Contains(value)) { return(this); } if (Count == 1) { return(Empty); } if (Count == 2) { return(_hashSet.Single(x => x != value)); } if (!IsSealed) { _hashSet.Remove(value); return(this); } var result = new HashSetScalars(); foreach (var element in this) { if (element != value) { result.Add(element); } } return(result); }
public IScalars Remove(Scalar value) { value.VerifyNotNull(nameof(value)); return(this); }
public IScalars Add(Scalar value) { value.VerifyNotNull(nameof(value)); return(value); }
public bool Contains(Scalar value) { value.VerifyNotNull(nameof(value)); return(false); }
public bool Contains(Scalar value) { value.VerifyNotNull(nameof(value)); return(_hashSet.Contains(value)); }