Example #1
0
        /// <summary>
        /// Unmarshals and deallocates a OPCBROWSEELEMENT structures.
        /// </summary>
        internal static TsCDaBrowseElement GetBrowseElement(IntPtr pInput, bool deallocate)
        {
            TsCDaBrowseElement output = null;

            if (pInput != IntPtr.Zero)
            {
                OpcRcw.Da.OPCBROWSEELEMENT element = (OpcRcw.Da.OPCBROWSEELEMENT)Marshal.PtrToStructure(pInput, typeof(OpcRcw.Da.OPCBROWSEELEMENT));

                output = new TsCDaBrowseElement();

                output.Name        = element.szName;
                output.ItemPath    = null;
                output.ItemName    = element.szItemID;
                output.IsItem      = ((element.dwFlagValue & OpcRcw.Da.Constants.OPC_BROWSE_ISITEM) != 0);
                output.HasChildren = ((element.dwFlagValue & OpcRcw.Da.Constants.OPC_BROWSE_HASCHILDREN) != 0);
                output.Properties  = GetItemProperties(ref element.ItemProperties, deallocate);

                if (deallocate)
                {
                    Marshal.DestroyStructure(pInput, typeof(OpcRcw.Da.OPCBROWSEELEMENT));
                }
            }

            return(output);
        }
Example #2
0
        /// <summary>
        /// Allocates and marshals an array of OPCBROWSEELEMENT structures.
        /// </summary>
        internal static IntPtr GetBrowseElements(TsCDaBrowseElement[] input, bool propertiesRequested)
        {
            IntPtr output = IntPtr.Zero;

            if (input != null && input.Length > 0)
            {
                output = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(OpcRcw.Da.OPCBROWSEELEMENT)) * input.Length);

                IntPtr pos = output;

                for (int ii = 0; ii < input.Length; ii++)
                {
                    OpcRcw.Da.OPCBROWSEELEMENT element = GetBrowseElement(input[ii], propertiesRequested);
                    Marshal.StructureToPtr(element, pos, false);
                    pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(OpcRcw.Da.OPCBROWSEELEMENT)));
                }
            }

            return(output);
        }
Example #3
0
        /// <summary>
        /// Allocates and marshals an OPCBROWSEELEMENT structure.
        /// </summary>
        internal static OpcRcw.Da.OPCBROWSEELEMENT GetBrowseElement(TsCDaBrowseElement input, bool propertiesRequested)
        {
            OpcRcw.Da.OPCBROWSEELEMENT output = new OpcRcw.Da.OPCBROWSEELEMENT();

            if (input != null)
            {
                output.szName         = input.Name;
                output.szItemID       = input.ItemName;
                output.dwFlagValue    = 0;
                output.ItemProperties = GetItemProperties(input.Properties);

                if (input.IsItem)
                {
                    output.dwFlagValue |= OpcRcw.Da.Constants.OPC_BROWSE_ISITEM;
                }

                if (input.HasChildren)
                {
                    output.dwFlagValue |= OpcRcw.Da.Constants.OPC_BROWSE_HASCHILDREN;
                }
            }

            return(output);
        }