Exemplo n.º 1
0
        /// <summary>
        /// Returns a filter that is the logical AND of the two specified filters.
        /// </summary>
        /// <param name="pA"></param>
        /// <param name="pB"></param>
        /// <returns></returns>
        public static cFilter operator &(cFilter pA, cFilter pB)
        {
            if (pA == null)
            {
                throw new ArgumentNullException(nameof(pA));
            }
            if (pB == null)
            {
                throw new ArgumentNullException(nameof(pB));
            }

            if (pA is cFilterFlagsContain lFCA && pB is cFilterFlagsContain lFCB)
            {
                cFetchableFlagList lFlags = new cFetchableFlagList();
                lFlags.Add(lFCA.Flags);
                lFlags.Add(lFCB.Flags);
                return(new cFilterFlagsContain(lFlags));
            }

            List <cFilter> lItems = new List <cFilter>();

            if (pA is cFilterAnd lAA)
            {
                lItems.AddRange(lAA.Terms);
            }
            else
            {
                lItems.Add(pA);
            }

            if (pB is cFilterAnd lAB)
            {
                lItems.AddRange(lAB.Terms);
            }
            else
            {
                lItems.Add(pB);
            }

            return(new cFilterAnd(lItems));
        }