Esempio n. 1
0
        /// <summary>
        /// Returns a list of references that match the direction and are subtypes of the reference type.
        /// </summary>
        /// <param name="referenceTypeId">The reference type identifier.</param>
        /// <param name="isInverse">if set to <c>true</c> this is inverse reference.</param>
        /// <param name="typeTree">The type tree.</param>
        /// <returns>A list of references that match the direction and are subtypes of the reference type.</returns>
        public IList <IReference> Find(
            NodeId referenceTypeId,
            bool isInverse,
            ITypeTable typeTree)
        {
            if (typeTree == null)
            {
                throw new ArgumentNullException("typeTree");
            }

            List <IReference> hits = new List <IReference>();

            // check for null.
            if (NodeId.IsNull(referenceTypeId))
            {
                return(hits);
            }

            foreach (KeyValuePair <NodeId, ReferenceTypeEntry> entry in m_references)
            {
                if (typeTree.IsTypeOf(entry.Key, referenceTypeId))
                {
                    Find(entry.Value, isInverse, hits);
                }
            }

            return(hits);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns true if the dictionary contains a reference that matches any subtype of the reference type.
        /// </summary>
        /// <param name="reference">The reference.</param>
        /// <param name="typeTree">The type tree.</param>
        /// <returns>
        ///     <c>true</c> if the dictionary contains key; otherwise, <c>false</c>.
        /// </returns>
        public bool ContainsKey(
            IReference reference,
            ITypeTable typeTree)
        {
            if (typeTree == null)
            {
                throw new ArgumentNullException("typeTree");
            }

            if (!ValidateReference(reference, false))
            {
                return(false);
            }

            foreach (KeyValuePair <NodeId, ReferenceTypeEntry> entry in m_references)
            {
                if (typeTree.IsTypeOf(entry.Key, reference.ReferenceTypeId))
                {
                    if (ContainsKey(entry.Value, reference))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }