Beispiel #1
0
        private void InitializeMessage(PortMessage existingMessage, MemoryRegion data, short dataLength)
        {
            if (dataLength > Win32.PortMessageMaxDataLength)
            {
                throw new ArgumentOutOfRangeException("Data length is too large.");
            }
            if (dataLength < 0)
            {
                throw new ArgumentOutOfRangeException("Data length cannot be negative.");
            }

            _message = new PortMessageStruct();

            _message.DataLength     = dataLength;
            _message.TotalLength    = (short)(_portMessageSize + dataLength);
            _message.DataInfoOffset = 0;

            if (existingMessage != null)
            {
                _message.ClientId  = existingMessage.ClientId;
                _message.MessageId = existingMessage.MessageId;
            }

            _data = data;

            _referencedData = data;
            _referencedData.Reference();
        }
        private void InitializeMessage(PortMessage existingMessage, MemoryRegion data, short dataLength)
        {
            if (dataLength > Win32.PortMessageMaxDataLength)
                throw new ArgumentOutOfRangeException("Data length is too large.");
            if (dataLength < 0)
                throw new ArgumentOutOfRangeException("Data length cannot be negative.");

            _message = new PortMessageStruct
            {
                DataLength = dataLength, 
                TotalLength = (short)(PortMessageStruct.SizeOf + dataLength), 
                DataInfoOffset = 0
            };

            if (existingMessage != null)
            {
                _message.ClientId = existingMessage.ClientId;
                _message.MessageId = existingMessage.MessageId;
            }

            _data = data;

            _referencedData = data;
            _referencedData.Reference();
        }
Beispiel #3
0
 public PortMessage(PortMessage existingMessage, byte[] data)
 {
     using (var alloc = new MemoryAlloc(data.Length))
     {
         alloc.WriteBytes(0, data);
         this.InitializeMessage(existingMessage, alloc, (short)alloc.Size);
     }
 }
Beispiel #4
0
 public PortMessage(PortMessage existingMessage, byte[] data)
 {
     using (var alloc = new MemoryAlloc(data.Length))
     {
         alloc.WriteBytes(0, data);
         this.InitializeMessage(existingMessage, alloc, (short)alloc.Size);
     }
 }
Beispiel #5
0
 public PortMessage(PortMessage existingMessage, MemoryRegion data, short dataLength)
 {
     this.InitializeMessage(existingMessage, data, dataLength);
 }
Beispiel #6
0
 public PortMessage(PortMessage existingMessage, MemoryRegion data, short dataLength)
 {
     this.InitializeMessage(existingMessage, data, dataLength);
 }