/// <summary>
        /// Writes the new PiPL resource to the specified unmanaged memory buffer.
        /// </summary>
        /// <param name="properties">The collection of PiPL resources to write.</param>
        /// <param name="buffer">The unmanaged memory buffer to write to.</param>
        /// <param name="bufferLength">The length of the unmanaged memory buffer.</param>
        /// <exception cref="ArgumentNullException"><paramref name="properties"/> is null.</exception>
        private static void WriteNewPIPLResource(ReadOnlyCollection <PIProperty> properties, IntPtr buffer, long bufferLength)
        {
            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            using (UnmanagedMemoryStreamEx stream = new UnmanagedMemoryStreamEx(buffer, bufferLength, FileAccess.Write))
            {
                // Write the PIPL resource header.
                stream.WriteInt16(PIPLConstants.ResourceSignature);
                stream.WriteInt32(PIPLConstants.ResourceVersion);
                stream.WriteInt32(properties.Count);

                // Write the PIPL resources.
                for (int i = 0; i < properties.Count; i++)
                {
                    properties[i].Write(stream);
                }
            }
        }
        /// <summary>
        /// Writes the <see cref="PIProperty"/> to the specified stream.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <exception cref="ArgumentNullException"><paramref name="stream"/> is null.</exception>
        public void Write(UnmanagedMemoryStreamEx stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            stream.WriteUInt32(vendorID);
            stream.WriteUInt32(propertyKey);
            stream.WriteInt32(propertyID);
            stream.WriteInt32(propertyDataLength);

            if (propertyData != null)
            {
                stream.Write(propertyData, 0, propertyData.Length);
                if (propertyDataPaddingLength > 0)
                {
                    byte[] padding = new byte[propertyDataPaddingLength];
                    stream.Write(padding, 0, propertyDataPaddingLength);
                }
            }
        }