示例#1
0
        internal static IntPtr GetBrowseElements(BrowseElement[] input, bool propertiesRequested)
        {
            IntPtr intPtr = IntPtr.Zero;

            if (input != null && input.Length > 0)
            {
                intPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(OPCBROWSEELEMENT)) * input.Length);
                IntPtr ptr = intPtr;
                for (int i = 0; i < input.Length; i++)
                {
                    OPCBROWSEELEMENT browseElement = GetBrowseElement(input[i], propertiesRequested);
                    Marshal.StructureToPtr((object)browseElement, ptr, fDeleteOld: false);
                    ptr = (IntPtr)(ptr.ToInt64() + Marshal.SizeOf(typeof(OPCBROWSEELEMENT)));
                }
            }

            return(intPtr);
        }
示例#2
0
        internal static OPCBROWSEELEMENT GetBrowseElement(BrowseElement input, bool propertiesRequested)
        {
            OPCBROWSEELEMENT opcbrowseelement = new OPCBROWSEELEMENT();

            if (input != null)
            {
                opcbrowseelement.szName         = input.Name;
                opcbrowseelement.szItemID       = input.ItemName;
                opcbrowseelement.dwFlagValue    = 0;
                opcbrowseelement.ItemProperties = GetItemProperties(input.Properties);
                if (input.IsItem)
                {
                    opcbrowseelement.dwFlagValue |= 2;
                }
                if (input.HasChildren)
                {
                    opcbrowseelement.dwFlagValue |= 1;
                }
            }
            return(opcbrowseelement);
        }
示例#3
0
        internal static BrowseElement GetBrowseElement(IntPtr pInput, bool deallocate)
        {
            BrowseElement element = null;

            if (pInput != IntPtr.Zero)
            {
                OPCBROWSEELEMENT opcbrowseelement = (OPCBROWSEELEMENT)Marshal.PtrToStructure(pInput, typeof(OPCBROWSEELEMENT));
                element = new BrowseElement {
                    Name        = opcbrowseelement.szName,
                    ItemPath    = null,
                    ItemName    = opcbrowseelement.szItemID,
                    IsItem      = (opcbrowseelement.dwFlagValue & 2) != 0,
                    HasChildren = (opcbrowseelement.dwFlagValue & 1) != 0,
                    Properties  = GetItemProperties(ref opcbrowseelement.ItemProperties, deallocate)
                };
                if (deallocate)
                {
                    Marshal.DestroyStructure(pInput, typeof(OPCBROWSEELEMENT));
                }
            }
            return(element);
        }
示例#4
0
        internal static BrowseElement GetBrowseElement(IntPtr pInput, bool deallocate)
        {
            BrowseElement browseElement = null;

            if (pInput != IntPtr.Zero)
            {
                OPCBROWSEELEMENT oPCBROWSEELEMENT = (OPCBROWSEELEMENT)Marshal.PtrToStructure(pInput, typeof(OPCBROWSEELEMENT));
                browseElement             = new BrowseElement();
                browseElement.Name        = oPCBROWSEELEMENT.szName;
                browseElement.ItemPath    = null;
                browseElement.ItemName    = oPCBROWSEELEMENT.szItemID;
                browseElement.IsItem      = ((oPCBROWSEELEMENT.dwFlagValue & 2) != 0);
                browseElement.HasChildren = ((oPCBROWSEELEMENT.dwFlagValue & 1) != 0);
                browseElement.Properties  = GetItemProperties(ref oPCBROWSEELEMENT.ItemProperties, deallocate);
                if (deallocate)
                {
                    Marshal.DestroyStructure(pInput, typeof(OPCBROWSEELEMENT));
                }
            }

            return(browseElement);
        }
示例#5
0
        internal static OPCBROWSEELEMENT GetBrowseElement(BrowseElement input, bool propertiesRequested)
        {
            OPCBROWSEELEMENT result = default(OPCBROWSEELEMENT);

            if (input != null)
            {
                result.szName         = input.Name;
                result.szItemID       = input.ItemName;
                result.dwFlagValue    = 0;
                result.ItemProperties = GetItemProperties(input.Properties);
                if (input.IsItem)
                {
                    result.dwFlagValue |= 2;
                }

                if (input.HasChildren)
                {
                    result.dwFlagValue |= 1;
                }
            }

            return(result);
        }