/// <summary>
        /// Look up the specified identity and return the object to which it
        /// refers.
        /// </summary>
        /// <param name="id">
        /// The identity.
        /// </param>
        /// <returns>
        /// The object registered under that identity.
        /// </returns>
        /// <exception cref="IOException">
        /// If the requested identity is not registered.
        /// </exception>
        protected internal IPofValue LookupIdentity(int id)
        {
            ILongArray map = EnsureReferenceRegistry();

            if (!map.Exists(id))
            {
                throw new IOException("missing identity: " + id);
            }

            return((IPofValue)map[id]);
        }
Пример #2
0
        /// <summary>
        /// Return index of the last parsed child with an index lower than the
        /// specified one.
        /// </summary>
        /// <param name="nIndex">
        /// Index to find the preceding child index for.
        /// </param>
        /// <returns>
        /// Index of the last parsed child, or -1 if one does not exist.
        /// </returns>
        protected int GetLastChildIndex(int nIndex)
        {
            ILongArray aChildren = m_aChildren;
            int        nLast     = (int)aChildren.LastIndex;

            if (nIndex < nLast)
            {
                nLast = nIndex;
                while (nLast >= 0 && !aChildren.Exists(nLast))
                {
                    nLast--;
                }
            }
            return(nLast);
        }