Ejemplo n.º 1
0
        /// <summary>Ensures set contain only elements that are present either in the current set or in the specified collection, but not both.</summary>
        /// <param name="source">The current set.</param>
        /// <param name="other">The collection to compare to the current set.</param>
        /// <returns>A new set if there is any modification to current sealed set; otherwise, the current set.</returns>
        public static IModels SymmetricExcept(this IModels source, IModels other)
        {
            source.VerifyNotNull(nameof(source));
            other.VerifyNotNull(nameof(other));

            IModels removedModelSet = Models.Empty;

            foreach (var item in source)
            {
                if (other.Contains(item))
                {
                    removedModelSet = removedModelSet.Add(item);
                    source          = source.Remove(item);
                }
            }

            foreach (var item in other)
            {
                if (removedModelSet.Contains(item))
                {
                    source = source.Add(item);
                }
            }

            return(source);
        }
Ejemplo n.º 2
0
        /// <summary>Ensures set contain all elements that are present in either the current set or in the specified collection.</summary>
        /// <param name="source">The current set.</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 IModels Union(this IModels source, IModels other)
        {
            source.VerifyNotNull(nameof(source));
            other.VerifyNotNull(nameof(other));

            foreach (var item in other)
            {
                source = source.Add(item);
            }
            return(source);
        }
Ejemplo n.º 3
0
        private void AddSourceModel(Model model)
        {
            Debug.Assert(!_sourceModels.Contains(model));

            _sourceModels = _sourceModels.Add(model);
            if (_autoColumnSelector == null)
            {
                _autoColumnSelector = model.Columns;
            }
            else
            {
                _autoColumnSelector = _autoColumnSelector.Merge(model.Columns);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a <see cref="IModels"/> object which contains specified <see cref="Model"/> values.
        /// </summary>
        /// <param name="values">The specified <see cref="Model"/> values.</param>
        /// <returns>The created result.</returns>
        public static IModels New(params Model[] values)
        {
            values.VerifyNotNull(nameof(values));

            if (values.Length == 0)
            {
                return(Empty);
            }

            IModels result = values.VerifyNotNull(0, nameof(values));

            for (int i = 1; i < values.Length; i++)
            {
                result = result.Add(values.VerifyNotNull(i, nameof(values)));
            }
            return(result);
        }