Example #1
0
            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));
        }
Example #3
0
        /// <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);
        }
Example #4
0
            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);
            }
Example #5
0
 public IScalars Remove(Scalar value)
 {
     value.VerifyNotNull(nameof(value));
     return(this);
 }
Example #6
0
 public IScalars Add(Scalar value)
 {
     value.VerifyNotNull(nameof(value));
     return(value);
 }
Example #7
0
 public bool Contains(Scalar value)
 {
     value.VerifyNotNull(nameof(value));
     return(false);
 }
Example #8
0
 public bool Contains(Scalar value)
 {
     value.VerifyNotNull(nameof(value));
     return(_hashSet.Contains(value));
 }