示例#1
0
        /// <summary>
        /// Creates an enumerator for the current browse position.
        /// </summary>
        /// <param name="branches">if set to <c>true</c> then browse branches.</param>
        /// <returns>The wrapped enumerator.</returns>
        private EnumString CreateEnumerator(bool branches)
        {
            IEnumString unknown = null;

            string methodName = "IOPCHDA_Browser.GetEnum";

            try
            {
                IOPCHDA_Browser server = BeginComCall <IOPCHDA_Browser>(methodName, true);

                OPCHDA_BROWSETYPE browseType = OPCHDA_BROWSETYPE.OPCHDA_ITEMS;

                if (branches)
                {
                    browseType = OPCHDA_BROWSETYPE.OPCHDA_BRANCH;
                }

                server.GetEnum(browseType, out unknown);
            }
            catch (Exception e)
            {
                ComCallError(methodName, e);
                return(null);
            }
            finally
            {
                EndComCall(methodName);
            }

            // wrapper the enumrator. hardcoding a buffer size of 256.
            return(new EnumString(unknown, 256));
        }
示例#2
0
 private EnumString GetEnumerator(bool isBranch)
 {
     try
     {
         OPCHDA_BROWSETYPE dwBrowseType  = isBranch ? OPCHDA_BROWSETYPE.OPCHDA_BRANCH : OPCHDA_BROWSETYPE.OPCHDA_LEAF;
         IEnumString       ppIEnumString = null;
         m_browser.GetEnum(dwBrowseType, out ppIEnumString);
         return(new EnumString(ppIEnumString));
     }
     catch (Exception e)
     {
         throw OpcCom.Interop.CreateException("IOPCHDA_Browser.GetEnum", e);
     }
 }