protected MsmqIntegrationInputMessage(SizeQuota bufferSizeQuota)
     : base(22, bufferSizeQuota)
 {
     this.acknowledge = new ByteProperty(this, UnsafeNativeMethods.PROPID_M_ACKNOWLEDGE);
     this.adminQueue = new StringProperty(this, UnsafeNativeMethods.PROPID_M_ADMIN_QUEUE, initialQueueNameLength);
     this.adminQueueLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_ADMIN_QUEUE_LEN, initialQueueNameLength);
     this.appSpecific = new IntProperty(this, UnsafeNativeMethods.PROPID_M_APPSPECIFIC);
     this.arrivedTime = new IntProperty(this, UnsafeNativeMethods.PROPID_M_ARRIVEDTIME);
     this.senderIdType = new IntProperty(this, UnsafeNativeMethods.PROPID_M_SENDERID_TYPE);
     this.authenticated = new ByteProperty(this, UnsafeNativeMethods.PROPID_M_AUTHENTICATED);
     this.bodyType = new IntProperty(this, UnsafeNativeMethods.PROPID_M_BODY_TYPE);
     this.correlationId = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_CORRELATIONID,
                                             UnsafeNativeMethods.PROPID_M_CORRELATIONID_SIZE);
     this.destinationQueue = new StringProperty(this, UnsafeNativeMethods.PROPID_M_DEST_FORMAT_NAME, initialQueueNameLength);
     this.destinationQueueLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_DEST_FORMAT_NAME_LEN, initialQueueNameLength);
     this.extension = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_EXTENSION,
                                         bufferSizeQuota.AllocIfAvailable(initialExtensionLength));
     this.extensionLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_EXTENSION_LEN, initialExtensionLength);
     this.label = new StringProperty(this, UnsafeNativeMethods.PROPID_M_LABEL, initialLabelLength);
     this.labelLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_LABEL_LEN, initialLabelLength);
     this.priority = new ByteProperty(this, UnsafeNativeMethods.PROPID_M_PRIORITY);
     this.responseFormatName = new StringProperty(this, UnsafeNativeMethods.PROPID_M_RESP_FORMAT_NAME, initialQueueNameLength);
     this.responseFormatNameLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_RESP_FORMAT_NAME_LEN, initialQueueNameLength);
     this.sentTime = new IntProperty(this, UnsafeNativeMethods.PROPID_M_SENTTIME);
     this.timeToReachQueue = new IntProperty(this, UnsafeNativeMethods.PROPID_M_TIME_TO_REACH_QUEUE);
     this.privacyLevel = new IntProperty(this, UnsafeNativeMethods.PROPID_M_PRIV_LEVEL);
 }
 protected MsmqIntegrationInputMessage(SizeQuota bufferSizeQuota)
     : base(22, bufferSizeQuota)
 {
     this.acknowledge      = new ByteProperty(this, UnsafeNativeMethods.PROPID_M_ACKNOWLEDGE);
     this.adminQueue       = new StringProperty(this, UnsafeNativeMethods.PROPID_M_ADMIN_QUEUE, initialQueueNameLength);
     this.adminQueueLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_ADMIN_QUEUE_LEN, initialQueueNameLength);
     this.appSpecific      = new IntProperty(this, UnsafeNativeMethods.PROPID_M_APPSPECIFIC);
     this.arrivedTime      = new IntProperty(this, UnsafeNativeMethods.PROPID_M_ARRIVEDTIME);
     this.senderIdType     = new IntProperty(this, UnsafeNativeMethods.PROPID_M_SENDERID_TYPE);
     this.authenticated    = new ByteProperty(this, UnsafeNativeMethods.PROPID_M_AUTHENTICATED);
     this.bodyType         = new IntProperty(this, UnsafeNativeMethods.PROPID_M_BODY_TYPE);
     this.correlationId    = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_CORRELATIONID,
                                                UnsafeNativeMethods.PROPID_M_CORRELATIONID_SIZE);
     this.destinationQueue       = new StringProperty(this, UnsafeNativeMethods.PROPID_M_DEST_FORMAT_NAME, initialQueueNameLength);
     this.destinationQueueLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_DEST_FORMAT_NAME_LEN, initialQueueNameLength);
     this.extension = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_EXTENSION,
                                         bufferSizeQuota.AllocIfAvailable(initialExtensionLength));
     this.extensionLength          = new IntProperty(this, UnsafeNativeMethods.PROPID_M_EXTENSION_LEN, initialExtensionLength);
     this.label                    = new StringProperty(this, UnsafeNativeMethods.PROPID_M_LABEL, initialLabelLength);
     this.labelLength              = new IntProperty(this, UnsafeNativeMethods.PROPID_M_LABEL_LEN, initialLabelLength);
     this.priority                 = new ByteProperty(this, UnsafeNativeMethods.PROPID_M_PRIORITY);
     this.responseFormatName       = new StringProperty(this, UnsafeNativeMethods.PROPID_M_RESP_FORMAT_NAME, initialQueueNameLength);
     this.responseFormatNameLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_RESP_FORMAT_NAME_LEN, initialQueueNameLength);
     this.sentTime                 = new IntProperty(this, UnsafeNativeMethods.PROPID_M_SENTTIME);
     this.timeToReachQueue         = new IntProperty(this, UnsafeNativeMethods.PROPID_M_TIME_TO_REACH_QUEUE);
     this.privacyLevel             = new IntProperty(this, UnsafeNativeMethods.PROPID_M_PRIV_LEVEL);
 }
 public void SetProperty(BufferProperty property)
 {
     foreach (var mat in materials)
     {
         mat.SetBuffer(property.name, property.val);
     }
     if (toGlobal)
     {
         Shader.SetGlobalBuffer(property.name, property.val);
     }
 }
 protected MsmqInputMessage(int additionalPropertyCount, SizeQuota bufferSizeQuota)
     : base(12 + additionalPropertyCount)
 {
     this.maxBufferSize = bufferSizeQuota.MaxSize;
     this.body = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_BODY,
         bufferSizeQuota.AllocIfAvailable(initialBodySize));
     this.bodyLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_BODY_SIZE);
     this.messageId = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_MSGID,
         UnsafeNativeMethods.PROPID_M_MSGID_SIZE);
     this.lookupId = new LongProperty(this, UnsafeNativeMethods.PROPID_M_LOOKUPID);
     this.cls = new ShortProperty(this, UnsafeNativeMethods.PROPID_M_CLASS);
     this.senderId = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_SENDERID, initialSenderIdSize);
     this.senderIdLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_SENDERID_LEN);
     this.senderCertificate = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_SENDER_CERT,
         bufferSizeQuota.AllocIfAvailable(initialCertificateSize));
     this.senderCertificateLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_SENDER_CERT_LEN);
     if (Msmq.IsAdvancedPoisonHandlingSupported)
     {
         this.lastMovedTime = new IntProperty(this, UnsafeNativeMethods.PROPID_M_LAST_MOVE_TIME);
         this.abortCount = new IntProperty(this, UnsafeNativeMethods.PROPID_M_ABORT_COUNT);
         this.moveCount = new IntProperty(this, UnsafeNativeMethods.PROPID_M_MOVE_COUNT);
     }
 }
 protected MsmqInputMessage(int additionalPropertyCount, SizeQuota bufferSizeQuota)
     : base(12 + additionalPropertyCount)
 {
     this.maxBufferSize = bufferSizeQuota.MaxSize;
     this.body          = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_BODY,
                                             bufferSizeQuota.AllocIfAvailable(initialBodySize));
     this.bodyLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_BODY_SIZE);
     this.messageId  = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_MSGID,
                                          UnsafeNativeMethods.PROPID_M_MSGID_SIZE);
     this.lookupId          = new LongProperty(this, UnsafeNativeMethods.PROPID_M_LOOKUPID);
     this.cls               = new ShortProperty(this, UnsafeNativeMethods.PROPID_M_CLASS);
     this.senderId          = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_SENDERID, initialSenderIdSize);
     this.senderIdLength    = new IntProperty(this, UnsafeNativeMethods.PROPID_M_SENDERID_LEN);
     this.senderCertificate = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_SENDER_CERT,
                                                 bufferSizeQuota.AllocIfAvailable(initialCertificateSize));
     this.senderCertificateLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_SENDER_CERT_LEN);
     if (Msmq.IsAdvancedPoisonHandlingSupported)
     {
         this.lastMovedTime = new IntProperty(this, UnsafeNativeMethods.PROPID_M_LAST_MOVE_TIME);
         this.abortCount    = new IntProperty(this, UnsafeNativeMethods.PROPID_M_ABORT_COUNT);
         this.moveCount     = new IntProperty(this, UnsafeNativeMethods.PROPID_M_MOVE_COUNT);
     }
 }
Ejemplo n.º 6
0
            protected void ParseCommand(byte data)
            {
                if (CommandSequence.Count == 0)
                {
                    if (data == '[')
                    {
                        CommandSequence.Add(data);
                    }
                    else
                    {
                        Debug.Log("Currently unsupported command sequence: " + (char)data);
                    }
                }
                else if (CommandSequence.Count >= 1)
                {
                    if (CommandSequence[0] == '[')
                    {
                        if (data >= '0' && data <= '9' || data == ';' || data == '?')
                        {
                            CommandSequence.Add(data);
                        }
                        else
                        {
                            int line   = -1;
                            int column = -1;
                            int count  = 0;
                            try
                            {
                                byte last = CommandSequence[CommandSequence.Count - 1];
                                // Move cursor up
                                if (data == 'A')
                                {
                                    count = GetCommandNumber(1, ref line);
                                    if (line < 0)
                                    {
                                        throw new Exception("Invalid 'A' command sequence");
                                    }
                                    SetCursor(CursorX, CursorY - line);
                                }
                                // Move cursor down
                                else if (data == 'B')
                                {
                                    count = GetCommandNumber(1, ref line);
                                    if (line < 0)
                                    {
                                        throw new Exception("Invalid 'B' command sequence");
                                    }
                                    SetCursor(CursorX, CursorY + line);
                                }
                                // Move cursor right
                                else if (data == 'C')
                                {
                                    count = GetCommandNumber(1, ref column);
                                    if (column < 0)
                                    {
                                        throw new Exception("Invalid 'C' command sequence");
                                    }
                                    SetCursor(CursorX + column, CursorY);
                                }
                                // Move cursor left
                                else if (data == 'D')
                                {
                                    count = GetCommandNumber(1, ref column);
                                    if (column < 0)
                                    {
                                        throw new Exception("Invalid 'D' command sequence");
                                    }
                                    SetCursor(CursorX - column, CursorY);
                                }
                                // Move cursor to position on the screen
                                else if (data == 'H' || data == 'f')
                                {
                                    if (last == ';' || last == '[')
                                    {
                                        line   = 0;
                                        column = 0;
                                    }
                                    else
                                    {
                                        count = GetCommandNumber(1, ref line);
                                        count = GetCommandNumber(2 + count, ref column);
                                    }
                                    if (line < 0 || column < 0)
                                    {
                                        throw new Exception("Invalid 'H' command sequence");
                                    }
                                    SetCursor(column, line);
                                }
                                // Clear screen
                                else if (data == 'J')
                                {
                                    // Clear down from the cursor
                                    if (last == '[' || last == '0')
                                    {
                                    }
                                    // Clear up from the cursor
                                    else if (last == '1')
                                    {
                                    }
                                    // Clear entire screen
                                    else if (last == '2')
                                    {
                                        Buffer           = null;
                                        BufferProperties = null;
                                        UpdateBufferSize();
                                        CursorX = 0;
                                        CursorY = 0;
                                        ScrollY = 0;
                                    }
                                    else
                                    {
                                        throw new Exception("Unknown 'J' command sequence");
                                    }
                                }
                                // Clear line
                                else if (data == 'K')
                                {
                                    // Clear to the right of the cursor
                                    if (last == '[' || last == '0')
                                    {
                                        for (int i = CursorX; i < Width; i++)
                                        {
                                            SetCharacter(CursorY, i, '\0');
                                        }
                                    }
                                    // Clear to the left of the cursor
                                    else if (last == '1')
                                    {
                                        for (int i = 0; i <= CursorX; i++)
                                        {
                                            SetCharacter(CursorY, i, '\0');
                                        }
                                        CursorX = 0;
                                    }
                                    // Clear entire line
                                    else if (last == '2')
                                    {
                                        Buffer[CursorY]           = new char[Width];
                                        BufferProperties[CursorY] = new BufferProperty[Width];
                                        CursorX = 0;
                                    }
                                    else
                                    {
                                        throw new Exception("Unknown 'K' command sequence");
                                    }
                                }
                                // Save cursor position
                                else if (data == 's')
                                {
                                    SavedCursorX = CursorX;
                                    SavedCursorY = CursorY;
                                }
                                // Restore cursor position
                                else if (data == 'u')
                                {
                                    CursorX = SavedCursorX;
                                    CursorY = SavedCursorY;
                                }
                                else if (data == 'm')
                                {
                                    int attr = -1;
                                    int i    = 1;
                                    while (i < CommandSequence.Count)
                                    {
                                        if ((char)CommandSequence[i] == ';')
                                        {
                                            i++;
                                        }
                                        count = GetCommandNumber(i, ref attr);
                                        i    += count;

                                        if (attr == 0)
                                        {
                                            CurrentProperty.Bold       = false;
                                            CurrentProperty.Colour     = Colours["xterm"][7];
                                            CurrentProperty.ColourAttr = 37;
                                        }
                                        else if (attr == 1)
                                        {
                                            CurrentProperty.Bold = true;
                                            if (CurrentProperty.ColourAttr >= 30 && CurrentProperty.ColourAttr <= 37)
                                            {
                                                int index = CurrentProperty.ColourAttr - 30 + 8;
                                                CurrentProperty.Colour = Colours["xterm"][index];
                                            }
                                        }
                                        else if (attr == 2)
                                        {
                                            CurrentProperty.Bold = false;
                                            if (CurrentProperty.ColourAttr >= 30 && CurrentProperty.ColourAttr <= 37)
                                            {
                                                int index = CurrentProperty.ColourAttr - 30;
                                                CurrentProperty.Colour = Colours["xterm"][index];
                                            }
                                        }
                                        else if (attr >= 30 && attr <= 37)
                                        {
                                            int bolden = CurrentProperty.Bold ? 8 : 0;
                                            int index  = attr - 30 + bolden;
                                            CurrentProperty.Colour     = Colours["xterm"][index];
                                            CurrentProperty.ColourAttr = (byte)attr;
                                        }
                                    }
                                }
                                else
                                {
                                    Debug.Log("Unknown command sequence");
                                }
                            }
                            catch (Exception exp)
                            {
                                Debug.Log(exp.Message + " | " + exp.StackTrace);
                            }
                            finally
                            {
                                CommandSequence = null;
                            }
                        }
                    }
                }
            }
            public MsmqIntegrationOutputMessage(
                MsmqChannelFactoryBase <IOutputChannel> factory,
                int bodySize,
                EndpointAddress remoteAddress,
                MsmqIntegrationMessageProperty property)
                : base(factory, bodySize, remoteAddress, 8)
            {
                if (null == property)
                {
                    Fx.Assert("MsmqIntegrationMessageProperty expected");
                }

                if (property.AcknowledgeType.HasValue)
                {
                    EnsureAcknowledgeProperty((byte)property.AcknowledgeType.Value);
                }

                if (null != property.AdministrationQueue)
                {
                    EnsureAdminQueueProperty(property.AdministrationQueue, false);
                }

                if (property.AppSpecific.HasValue)
                {
                    this.appSpecific = new IntProperty(this, UnsafeNativeMethods.PROPID_M_APPSPECIFIC, property.AppSpecific.Value);
                }

                if (property.BodyType.HasValue)
                {
                    EnsureBodyTypeProperty(property.BodyType.Value);
                }

                if (null != property.CorrelationId)
                {
                    this.correlationId = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_CORRELATIONID, MsmqMessageId.FromString(property.CorrelationId));
                }

                if (null != property.Extension)
                {
                    this.extension = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_EXTENSION, property.Extension);
                }

                if (null != property.Label)
                {
                    this.label = new StringProperty(this, UnsafeNativeMethods.PROPID_M_LABEL, property.Label);
                }

                if (property.Priority.HasValue)
                {
                    this.priority = new ByteProperty(this, UnsafeNativeMethods.PROPID_M_PRIORITY, (byte)property.Priority.Value);
                }

                if (null != property.ResponseQueue)
                {
                    EnsureResponseQueueProperty(property.ResponseQueue);
                }

                if (property.TimeToReachQueue.HasValue)
                {
                    EnsureTimeToReachQueueProperty(MsmqDuration.FromTimeSpan(property.TimeToReachQueue.Value));
                }
            }
Ejemplo n.º 8
0
        protected MsmqOutputMessage(MsmqChannelFactoryBase <TChannel> factory, int bodySize, EndpointAddress remoteAddress, int additionalPropertyCount)
            : base(15 + additionalPropertyCount)
        {
            this.body      = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_BODY, bodySize);
            this.messageId = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_MSGID, UnsafeNativeMethods.PROPID_M_MSGID_SIZE);

            EnsureBodyTypeProperty(UnsafeNativeMethods.VT_VECTOR | UnsafeNativeMethods.VT_UI1);
            EnsureJournalProperty((byte)UnsafeNativeMethods.MQMSG_JOURNAL, factory.UseSourceJournal);

            this.delivery = new ByteProperty(this, UnsafeNativeMethods.PROPID_M_DELIVERY);
            if (factory.Durable)
            {
                this.delivery.Value = (byte)UnsafeNativeMethods.MQMSG_DELIVERY_RECOVERABLE;
            }
            else
            {
                this.delivery.Value = (byte)UnsafeNativeMethods.MQMSG_DELIVERY_EXPRESS;
            }

            if (factory.TimeToLive != TimeSpan.MaxValue)
            {
                int totalSeconds = MsmqDuration.FromTimeSpan(factory.TimeToLive);

                EnsureTimeToReachQueueProperty(totalSeconds);

                this.timeToBeReceived = new IntProperty(this,
                                                        UnsafeNativeMethods.PROPID_M_TIME_TO_BE_RECEIVED, totalSeconds);
            }

            switch (factory.DeadLetterQueue)
            {
            case DeadLetterQueue.None:
                EnsureJournalProperty((byte)UnsafeNativeMethods.MQMSG_DEADLETTER, false);
                break;

            case DeadLetterQueue.System:
                EnsureJournalProperty((byte)UnsafeNativeMethods.MQMSG_DEADLETTER, true);
                break;

            case DeadLetterQueue.Custom:
                EnsureJournalProperty((byte)UnsafeNativeMethods.MQMSG_DEADLETTER, true);
                EnsureDeadLetterQueueProperty(factory.DeadLetterQueuePathName);
                break;
            }

            if (MsmqAuthenticationMode.WindowsDomain == factory.MsmqTransportSecurity.MsmqAuthenticationMode)
            {
                EnsureSenderIdTypeProperty(UnsafeNativeMethods.MQMSG_SENDERID_TYPE_SID);

                this.authLevel = new IntProperty(this, UnsafeNativeMethods.PROPID_M_AUTH_LEVEL,
                                                 UnsafeNativeMethods.MQMSG_AUTH_LEVEL_ALWAYS);

                this.hashAlgorithm = new IntProperty(
                    this,
                    UnsafeNativeMethods.PROPID_M_HASH_ALG,
                    MsmqSecureHashAlgorithmHelper.ToInt32(factory.MsmqTransportSecurity.MsmqSecureHashAlgorithm));

                if (ProtectionLevel.EncryptAndSign == factory.MsmqTransportSecurity.MsmqProtectionLevel)
                {
                    this.privLevel = new IntProperty(this, UnsafeNativeMethods.PROPID_M_PRIV_LEVEL,
                                                     UnsafeNativeMethods.MQMSG_PRIV_LEVEL_BODY_ENHANCED);

                    this.encryptionAlgorithm = new IntProperty(
                        this,
                        UnsafeNativeMethods.PROPID_M_ENCRYPTION_ALG,
                        MsmqEncryptionAlgorithmHelper.ToInt32(factory.MsmqTransportSecurity.MsmqEncryptionAlgorithm));
                }
            }
            else if (MsmqAuthenticationMode.Certificate == factory.MsmqTransportSecurity.MsmqAuthenticationMode)
            {
                this.authLevel = new IntProperty(this, UnsafeNativeMethods.PROPID_M_AUTH_LEVEL,
                                                 UnsafeNativeMethods.MQMSG_AUTH_LEVEL_ALWAYS);

                this.hashAlgorithm = new IntProperty(
                    this,
                    UnsafeNativeMethods.PROPID_M_HASH_ALG,
                    MsmqSecureHashAlgorithmHelper.ToInt32(factory.MsmqTransportSecurity.MsmqSecureHashAlgorithm));

                if (ProtectionLevel.EncryptAndSign == factory.MsmqTransportSecurity.MsmqProtectionLevel)
                {
                    this.privLevel = new IntProperty(this, UnsafeNativeMethods.PROPID_M_PRIV_LEVEL,
                                                     UnsafeNativeMethods.MQMSG_PRIV_LEVEL_BODY_ENHANCED);

                    this.encryptionAlgorithm = new IntProperty(
                        this,
                        UnsafeNativeMethods.PROPID_M_ENCRYPTION_ALG,
                        MsmqEncryptionAlgorithmHelper.ToInt32(factory.MsmqTransportSecurity.MsmqEncryptionAlgorithm));
                }

                EnsureSenderIdTypeProperty(UnsafeNativeMethods.MQMSG_SENDERID_TYPE_NONE);
                this.senderCert = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_SENDER_CERT);
            }
            else
            {
                this.authLevel = new IntProperty(this, UnsafeNativeMethods.PROPID_M_AUTH_LEVEL,
                                                 UnsafeNativeMethods.MQMSG_AUTH_LEVEL_NONE);

                EnsureSenderIdTypeProperty(UnsafeNativeMethods.MQMSG_SENDERID_TYPE_NONE);
            }

            this.trace = new ByteProperty(this, UnsafeNativeMethods.PROPID_M_TRACE, (byte)(factory.UseMsmqTracing ?
                                                                                           UnsafeNativeMethods.MQMSG_SEND_ROUTE_TO_REPORT_QUEUE : UnsafeNativeMethods.MQMSG_TRACE_NONE));
        }