Пример #1
0
 // Token: 0x060000A1 RID: 161 RVA: 0x000043D7 File Offset: 0x000033D7
 public BrowseElement[] BrowseNext(int maxElements, ref IBrowsePosition position)
 {
     if (this.m_server == null)
     {
         throw new NotConnectedException();
     }
     return(((IServer)this.m_server).BrowseNext(maxElements, ref position));
 }
Пример #2
0
        public BrowseElement[] Browse(ItemIdentifier itemID)
        {
            IBrowsePosition position = null;

            BrowseElement[] result = Browse(itemID, 0, out position);
            position?.Dispose();
            return(result);
        }
Пример #3
0
        public BrowseElement[] BrowseNext(int maxElements, ref IBrowsePosition position)
        {
            if (position == null || (object)position.GetType() != typeof(BrowsePosition))
            {
                throw new ArgumentException("Not a valid browse position object.", "position");
            }

            if (maxElements <= 0)
            {
                maxElements = int.MaxValue;
            }

            lock (this)
            {
                BrowsePosition browsePosition = (BrowsePosition)position;
                ArrayList      arrayList      = new ArrayList();
                if (!browsePosition.FetchingItems)
                {
                    arrayList = FetchElements(browsePosition.Enumerator, maxElements, isBranch: true);
                    if (arrayList.Count >= maxElements)
                    {
                        return((BrowseElement[])arrayList.ToArray(typeof(BrowseElement)));
                    }

                    browsePosition.Enumerator.Dispose();
                    browsePosition.Enumerator    = null;
                    browsePosition.FetchingItems = true;
                    try
                    {
                        m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, browsePosition.BranchPath);
                    }
                    catch (Exception e)
                    {
                        throw OpcCom.Interop.CreateException("IOPCHDA_Browser.ChangeBrowsePosition", e);
                    }

                    browsePosition.Enumerator = GetEnumerator(isBranch: false);
                }

                ArrayList arrayList2 = FetchElements(browsePosition.Enumerator, maxElements - arrayList.Count, isBranch: false);
                if (arrayList2 != null)
                {
                    arrayList.AddRange(arrayList2);
                }

                if (arrayList.Count >= maxElements)
                {
                    return((BrowseElement[])arrayList.ToArray(typeof(BrowseElement)));
                }

                position.Dispose();
                position = null;
                return((BrowseElement[])arrayList.ToArray(typeof(BrowseElement)));
            }
        }
Пример #4
0
        public BrowseElement[] Browse(ItemIdentifier itemID)
        {
            IBrowsePosition position = null;

            BrowseElement[] elementArray = this.Browse(itemID, 0, out position);
            if (position != null)
            {
                position.Dispose();
            }
            return(elementArray);
        }
Пример #5
0
 public BrowseElement[] Browse(string areaID, BrowseType browseType, string browseFilter)
 {
     lock (this)
     {
         IBrowsePosition position = null;
         BrowseElement[] elementArray = this.Browse(areaID, browseType, browseFilter, 0, out position);
         if (position != null)
         {
             position.Dispose();
         }
         return elementArray;
     }
 }
Пример #6
0
        /// <summary>
        /// Browses for all children of the specified area that meet the filter criteria.
        /// </summary>
        /// <param name="areaID">The full-qualified id for the area.</param>
        /// <param name="browseType">The type of children to return.</param>
        /// <param name="browseFilter">The expression used to filter the names of children returned.</param>
        /// <param name="maxElements">The maximum number of elements to return.</param>
        /// <param name="position">The object used to continue the browse if the number nodes exceeds the maximum specified.</param>
        /// <returns>The set of elements that meet the filter criteria.</returns>
        public BrowseElement[]  Browse(
            string areaID,
            BrowseType browseType,
            string browseFilter,
            int maxElements,
            out IBrowsePosition position)
        {
            if (m_server == null)
            {
                throw new NotConnectedException();
            }

            return(((IServer)m_server).Browse(areaID, browseType, browseFilter, maxElements, out position));
        }
Пример #7
0
 public BrowseElement[] BrowseNext(int maxElements, ref IBrowsePosition position)
 {
     if ((position == null) || (position.GetType() != typeof(OpcCom.Hda.BrowsePosition)))
     {
         throw new ArgumentException("Not a valid browse position object.", "position");
     }
     if (maxElements <= 0)
     {
         maxElements = 0x7fffffff;
     }
     lock (this)
     {
         OpcCom.Hda.BrowsePosition position2 = (OpcCom.Hda.BrowsePosition)position;
         ArrayList list = new ArrayList();
         if (!position2.FetchingItems)
         {
             list = this.FetchElements(position2.Enumerator, maxElements, true);
             if (list.Count >= maxElements)
             {
                 return((BrowseElement[])list.ToArray(typeof(BrowseElement)));
             }
             position2.Enumerator.Dispose();
             position2.Enumerator    = null;
             position2.FetchingItems = true;
             try
             {
                 this.m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, position2.BranchPath);
             }
             catch (Exception exception)
             {
                 throw OpcCom.Interop.CreateException("IOPCHDA_Browser.ChangeBrowsePosition", exception);
             }
             position2.Enumerator = this.GetEnumerator(false);
         }
         ArrayList c = this.FetchElements(position2.Enumerator, maxElements - list.Count, false);
         if (c != null)
         {
             list.AddRange(c);
         }
         if (list.Count < maxElements)
         {
             position.Dispose();
             position = null;
         }
         return((BrowseElement[])list.ToArray(typeof(BrowseElement)));
     }
 }
Пример #8
0
        public BrowseElement[] Browse(ItemIdentifier itemID, int maxElements, out IBrowsePosition position)
        {
            position = null;
            if (maxElements <= 0)
            {
                maxElements = int.MaxValue;
            }

            lock (this)
            {
                string text = (itemID != null && itemID.ItemName != null) ? itemID.ItemName : "";
                try
                {
                    m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, text);
                }
                catch (Exception e)
                {
                    throw OpcCom.Interop.CreateException("IOPCHDA_Browser.ChangeBrowsePosition", e);
                }

                EnumString enumerator = GetEnumerator(isBranch: true);
                ArrayList  arrayList  = FetchElements(enumerator, maxElements, isBranch: true);
                if (arrayList.Count >= maxElements)
                {
                    position = new BrowsePosition(text, enumerator, fetchingItems: false);
                    return((BrowseElement[])arrayList.ToArray(typeof(BrowseElement)));
                }

                enumerator.Dispose();
                enumerator = GetEnumerator(isBranch: false);
                ArrayList arrayList2 = FetchElements(enumerator, maxElements - arrayList.Count, isBranch: false);
                if (arrayList2 != null)
                {
                    arrayList.AddRange(arrayList2);
                }

                if (arrayList.Count >= maxElements)
                {
                    position = new BrowsePosition(text, enumerator, fetchingItems: true);
                    return((BrowseElement[])arrayList.ToArray(typeof(BrowseElement)));
                }

                enumerator.Dispose();
                return((BrowseElement[])arrayList.ToArray(typeof(BrowseElement)));
            }
        }
Пример #9
0
 public BrowseElement[] Browse(ItemIdentifier itemID, int maxElements, out IBrowsePosition position)
 {
     position = null;
     if (maxElements <= 0)
     {
         maxElements = 0x7fffffff;
     }
     lock (this)
     {
         string szString = ((itemID != null) && (itemID.ItemName != null)) ? itemID.ItemName : "";
         try
         {
             this.m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, szString);
         }
         catch (Exception exception)
         {
             throw OpcCom.Interop.CreateException("IOPCHDA_Browser.ChangeBrowsePosition", exception);
         }
         EnumString enumerator = this.GetEnumerator(true);
         ArrayList  list       = this.FetchElements(enumerator, maxElements, true);
         if (list.Count >= maxElements)
         {
             position = new OpcCom.Hda.BrowsePosition(szString, enumerator, false);
             return((BrowseElement[])list.ToArray(typeof(BrowseElement)));
         }
         enumerator.Dispose();
         enumerator = this.GetEnumerator(false);
         ArrayList c = this.FetchElements(enumerator, maxElements - list.Count, false);
         if (c != null)
         {
             list.AddRange(c);
         }
         if (list.Count >= maxElements)
         {
             position = new OpcCom.Hda.BrowsePosition(szString, enumerator, true);
             return((BrowseElement[])list.ToArray(typeof(BrowseElement)));
         }
         enumerator.Dispose();
         return((BrowseElement[])list.ToArray(typeof(BrowseElement)));
     }
 }
Пример #10
0
 public BrowseElement[] BrowseNext(int maxElements, ref IBrowsePosition position)
 {
     lock (this)
     {
         if (base.m_server == null)
         {
             throw new NotConnectedException();
         }
         if (position == null)
         {
             throw new ArgumentNullException("position");
         }
         this.InitializeBrowser();
         this.ChangeBrowsePosition(((OpcCom.Ae.BrowsePosition) position).AreaID);
         UCOMIEnumString enumerator = ((OpcCom.Ae.BrowsePosition) position).Enumerator;
         ArrayList elements = new ArrayList();
         if (this.FetchElements(((OpcCom.Ae.BrowsePosition) position).BrowseType, maxElements, enumerator, elements) != 0)
         {
             position.Dispose();
             position = null;
         }
         return (BrowseElement[]) elements.ToArray(typeof(BrowseElement));
     }
 }
Пример #11
0
 public BrowseElement[] Browse(string areaID, BrowseType browseType, string browseFilter, int maxElements, out IBrowsePosition position)
 {
     position = null;
     lock (this)
     {
         if (base.m_server == null)
         {
             throw new NotConnectedException();
         }
         this.InitializeBrowser();
         this.ChangeBrowsePosition(areaID);
         UCOMIEnumString enumerator = (UCOMIEnumString) this.CreateEnumerator(browseType, browseFilter);
         ArrayList elements = new ArrayList();
         if (this.FetchElements(browseType, maxElements, enumerator, elements) != 0)
         {
             OpcCom.Interop.ReleaseServer(enumerator);
         }
         else
         {
             position = new OpcCom.Ae.BrowsePosition(areaID, browseType, browseFilter, enumerator);
         }
         return (BrowseElement[]) elements.ToArray(typeof(BrowseElement));
     }
 }
Пример #12
0
        //======================================================================
        // BrowseNext

        /// <summary>
        /// Continues browsing the server's address space at the specified position.
        /// </summary>
        /// <param name="maxElements">The maximum number of elements to return.</param>
        /// <param name="position">The position object used to continue a browse operation.</param>
        /// <returns>The set of elements that meet the filter criteria.</returns>
        public BrowseElement[] BrowseNext(int maxElements, ref IBrowsePosition position)
        {
            // check arguments.
            if (position == null || position.GetType() != typeof(OpcCom.Hda.BrowsePosition))
            {
                throw new ArgumentException("Not a valid browse position object.", "position");
            }

            // interpret invalid values as 'no limit'.
            if (maxElements <= 0)
            {
                maxElements = Int32.MaxValue;
            }

            lock (this)
            {
                OpcCom.Hda.BrowsePosition pos = (OpcCom.Hda.BrowsePosition)position;

                ArrayList elements = new ArrayList();

                if (!pos.FetchingItems)
                {
                    elements = FetchElements(pos.Enumerator, maxElements, true);

                    // check if max element count reached.
                    if (elements.Count >= maxElements)
                    {
                        return((BrowseElement[])elements.ToArray(typeof(BrowseElement)));
                    }

                    // release enumerator.
                    pos.Enumerator.Dispose();

                    pos.Enumerator    = null;
                    pos.FetchingItems = true;

                    // move to the correct position in the server's address space.
                    try
                    {
                        m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, pos.BranchPath);
                    }
                    catch (Exception e)
                    {
                        throw OpcCom.Interop.CreateException("IOPCHDA_Browser.ChangeBrowsePosition", e);
                    }

                    // create enumerator for items.
                    pos.Enumerator = GetEnumerator(false);
                }

                // fetch next set of items.
                ArrayList items = FetchElements(pos.Enumerator, maxElements - elements.Count, false);

                if (items != null)
                {
                    elements.AddRange(items);
                }

                // check if max element count reached.
                if (elements.Count >= maxElements)
                {
                    return((BrowseElement[])elements.ToArray(typeof(BrowseElement)));
                }

                // release position object.
                position.Dispose();
                position = null;

                // return elements.
                return((BrowseElement[])elements.ToArray(typeof(BrowseElement)));
            }
        }
Пример #13
0
        /// <summary>
        /// Begins a browsing the server's address space at the specified branch.
        /// </summary>
        /// <param name="itemID">The item id of the branch to search.</param>
        /// <param name="maxElements">The maximum number of elements to return.</param>
        /// <param name="position">The position object used to continue a browse operation.</param>
        /// <returns>The set of elements that meet the filter criteria.</returns>
        public BrowseElement[] Browse(ItemIdentifier itemID, int maxElements, out IBrowsePosition position)
        {
            position = null;

            // interpret invalid values as 'no limit'.
            if (maxElements <= 0)
            {
                maxElements = Int32.MaxValue;
            }

            lock (this)
            {
                string branchPath = (itemID != null && itemID.ItemName != null)?itemID.ItemName:"";

                // move to the correct position in the server's address space.
                try
                {
                    m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, branchPath);
                }
                catch (Exception e)
                {
                    throw OpcCom.Interop.CreateException("IOPCHDA_Browser.ChangeBrowsePosition", e);
                }

                // browse for branches
                EnumString enumerator = GetEnumerator(true);

                ArrayList elements = FetchElements(enumerator, maxElements, true);

                // check if max element count reached.
                if (elements.Count >= maxElements)
                {
                    position = new BrowsePosition(branchPath, enumerator, false);
                    return((BrowseElement[])elements.ToArray(typeof(BrowseElement)));
                }

                // release enumerator.
                enumerator.Dispose();

                // browse for items
                enumerator = GetEnumerator(false);

                ArrayList items = FetchElements(enumerator, maxElements - elements.Count, false);

                if (items != null)
                {
                    elements.AddRange(items);
                }

                // check if max element count reached.
                if (elements.Count >= maxElements)
                {
                    position = new BrowsePosition(branchPath, enumerator, true);
                    return((BrowseElement[])elements.ToArray(typeof(BrowseElement)));
                }

                // release enumerator.
                enumerator.Dispose();

                return((BrowseElement[])elements.ToArray(typeof(BrowseElement)));
            }
        }