Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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);
        }