/// <summary>
        /// Override to filter the specified properties.
        /// </summary>
        public override int get_VecItem(int hvo, int tag, int index)
        {
            ITestItem tester;

            if (!m_filterFlids.TryGetValue(tag, out tester))
            {
                return(base.get_VecItem(hvo, tag, index));
            }
            int chvoReal = BaseSda.get_VecSize(hvo, tag);

            using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative(chvoReal, typeof(int)))
            {
                BaseSda.VecProp(hvo, tag, chvoReal, out chvoReal, arrayPtr);
                int[] candidates = (int[])MarshalEx.NativeToArray(arrayPtr, chvoReal, typeof(int));
                int   iresult    = 0;
                for (int icandidate = 0; icandidate < candidates.Length; icandidate++)
                {
                    if (tester.Test(candidates[icandidate], BaseSda, m_validHvos))
                    {
                        if (iresult == index)
                        {
                            return(candidates[icandidate]);
                        }
                        iresult++;
                    }
                }
                throw new IndexOutOfRangeException("filtered vector does not contain that many items (wanted " + index +
                                                   " but have only " + iresult + ")");
            }
        }
        /// <summary>
        /// Override to filter the specified properties.
        /// </summary>
        public override void VecProp(int hvo, int tag, int chvoMax, out int chvo, ArrayPtr rghvo)
        {
            ITestItem tester;

            if (!m_filterFlids.TryGetValue(tag, out tester))
            {
                base.VecProp(hvo, tag, chvoMax, out chvo, rghvo);
                return;
            }
            int chvoReal = BaseSda.get_VecSize(hvo, tag);

            using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative(chvoReal, typeof(int)))
            {
                BaseSda.VecProp(hvo, tag, chvoReal, out chvoReal, arrayPtr);
                int[] candidates = (int[])MarshalEx.NativeToArray(arrayPtr, chvoReal, typeof(int));
                int[] results    = new int[chvoMax];
                int   iresult    = 0;
                for (int icandidate = 0; icandidate < candidates.Length; icandidate++)
                {
                    if (tester.Test(candidates[icandidate], BaseSda, m_validHvos))
                    {
                        results[iresult++] = candidates[icandidate];
                    }
                }
                chvo = iresult;
                MarshalEx.ArrayToNative(rghvo, chvoMax, results);
            }
        }
        /// <summary>
        /// Override to filter the specified properties.
        /// </summary>
        public override int get_VecSize(int hvo, int tag)
        {
            ITestItem tester;

            if (!m_filterFlids.TryGetValue(tag, out tester))
            {
                return(base.get_VecSize(hvo, tag));
            }
            int chvoReal = BaseSda.get_VecSize(hvo, tag);

            using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative(chvoReal, typeof(int)))
            {
                BaseSda.VecProp(hvo, tag, chvoReal, out chvoReal, arrayPtr);
                int[] candidates = (int[])MarshalEx.NativeToArray(arrayPtr, chvoReal, typeof(int));
                int   iresult    = 0;
                for (int icandidate = 0; icandidate < candidates.Length; icandidate++)
                {
                    if (tester.Test(candidates[icandidate], BaseSda, m_validHvos))
                    {
                        iresult++;
                    }
                }
                return(iresult);
            }
        }
        /// <summary>
        /// Make one that wraps the specified cache and passes items in the specified property of the specified root object.
        /// </summary>
        public FilterSdaDecorator(ISilDataAccess domainDataByFlid, int mainFlid, int hvoRoot)
            : base(domainDataByFlid)
        {
            m_mainFlid = mainFlid;
            m_hvoRoot  = hvoRoot;
            int chvoReal = BaseSda.get_VecSize(m_hvoRoot, m_mainFlid);

            using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative(chvoReal, typeof(int)))
            {
                BaseSda.VecProp(m_hvoRoot, m_mainFlid, chvoReal, out chvoReal, arrayPtr);
                m_validHvos = new Set <int>((int[])MarshalEx.NativeToArray(arrayPtr, chvoReal, typeof(int)));
            }
        }