コード例 #1
0
        /// <summary>
        /// Browses for children of the specified item.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="elementFilter">The element filter.</param>
        /// <param name="nameFilter">The name filter.</param>
        /// <param name="dataTypeFilter">The data type filter.</param>
        /// <param name="accessRightsFilter">The access rights filter.</param>
        /// <returns>
        /// The list of names that meet the criteria.
        /// </returns>
        public IList <string> BrowseForNames(
            Session session,
            BrowseElementFilter elementFilter,
            string nameFilter,
            short dataTypeFilter,
            int accessRightsFilter)
        {
            // find the id of the current element.
            string itemId = null;

            lock (m_lock)
            {
                if (m_browsePosition != null)
                {
                    itemId = m_browsePosition.ItemId;
                }
            }

            // find the names.
            IList <string> hits = m_cache.BrowseForNames(
                session,
                itemId,
                elementFilter,
                nameFilter,
                dataTypeFilter,
                accessRightsFilter);

            if (hits == null)
            {
                throw ComUtils.CreateComException(ResultIds.E_UNKNOWNITEMID);
            }

            // return the names.
            return(hits);
        }
コード例 #2
0
        /// <summary>
        /// Browses for children of the specified item.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="elementFilter">The element filter.</param>
        /// <param name="nameFilter">The name filter.</param>
        /// <param name="dataTypeFilter">The data type filter.</param>
        /// <param name="accessRightsFilter">The access rights filter.</param>
        /// <returns>
        /// The list of names that meet the criteria.
        /// </returns>
        public IList<string> BrowseForNames(
            Session session,
            BrowseElementFilter elementFilter,
            string nameFilter,
            short dataTypeFilter,
            int accessRightsFilter)
        {
            // find the id of the current element.
            string itemId = null;

            lock (m_lock)
            {
                if (m_browsePosition != null)
                {
                    itemId = m_browsePosition.ItemId;
                }
            }

            // find the names.
            IList<string> hits = m_cache.BrowseForNames(
                session,
                itemId, 
                elementFilter, 
                nameFilter, 
                dataTypeFilter, 
                accessRightsFilter);

            if (hits == null)
            {
                throw ComUtils.CreateComException(ResultIds.E_UNKNOWNITEMID);
            }

            // return the names.
            return hits;
        }
コード例 #3
0
        /// <summary>
        /// Browses for children of the specified item.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="itemId">The item id.</param>
        /// <param name="elementFilter">The element filter.</param>
        /// <param name="nameFilter">The name filter.</param>
        /// <param name="dataTypeFilter">The data type filter.</param>
        /// <param name="accessRightsFilter">The access rights filter.</param>
        /// <returns>
        /// The list of names that meet the criteria.
        /// </returns>
        public IList<string> BrowseForNames(
            Session session,
            string itemId,
            BrowseElementFilter elementFilter,
            string nameFilter,
            short dataTypeFilter,
            int accessRightsFilter)
        {
            TraceState("BrowseForNames", itemId, elementFilter, nameFilter, dataTypeFilter, accessRightsFilter);

            // look up the parent.
            BrowseElement parent = Lookup(session, itemId);

            if (parent == null)
            {
                return null;
            }

            // fetch the children.
            List<BrowseElement> children = LookupChildElements(session, parent);

            // search the children.
            List<string> hits = new List<string>();

            for (int ii = 0; ii < children.Count; ii++)
            {
                BrowseElement child = children[ii];

                // apply the name filter.
                if (!String.IsNullOrEmpty(nameFilter))
                {
                    if (!ComUtils.Match(child.BrowseName, nameFilter, false))
                    {
                        continue;
                    }
                }

                // branches must have children.
                if (elementFilter == BrowseElementFilter.Branch)
                {
                    if (child.NodeClass == NodeClass.Variable && child.ReferencesByName.Count == 0)
                    {
                        continue;
                    }
                }

                // items must be variables.
                if (elementFilter == BrowseElementFilter.Item)
                {
                    if (child.NodeClass != NodeClass.Variable)
                    {
                        continue;
                    }
                }

                if (child.NodeClass == NodeClass.Variable)
                {
                    // apply data type filter.
                    if (dataTypeFilter != 0)
                    {
                        if (child.CanonicalDataType != dataTypeFilter)
                        {
                            continue;
                        }
                    }

                    // apply access rights filter.
                    if (accessRightsFilter != 0)
                    {
                        if ((child.AccessRights & accessRightsFilter) == 0)
                        {
                            continue;
                        }
                    }
                }

                // a match.
                hits.Add(child.BrowseName);
            }

            // return all of the matching names.
            return hits;
        }