Audit.Views.ModifyMessage.BindMessage C# (CSharp) Method

BindMessage() public method

public BindMessage ( Type messageType, object instance ) : void
messageType Type
instance object
return void
        public void BindMessage(Type messageType, object instance)
        {
            MessageType = messageType;
            richTextBox1.Text = JsvFormatter.Format(JsonSerializer.SerializeToString(instance));
        }

Usage Example

Example #1
0
        void ModifySendMenuItemClick(object sender, EventArgs e)
        {
            if (_domainGrid.SelectedRows.Count == 0)
            {
                Log(@"No commands to send.");
                return;
            }

            // don`t resend set of commands
            if (_domainGrid.SelectedRows.Count > 1)
            {
                Log("Selected too many commands. Please, select only one!");
                return;
            }

            try
            {
                var items = _domainGrid.SelectedRows
                            .Cast <DataGridViewRow>()
                            .Select(i => (DomainLogDisplayItem)i.DataBoundItem)
                            .SelectMany(d => d.Item.Items)
                            .ToList();

                // don`t resend set of commands
                if (items.Count > 1)
                {
                    Log("Too many commands in selected envelope. Please, select only one!");
                    return;
                }

                var envelope = items.Single();
                using (var m = new ModifyMessage())
                {
                    m.BindMessage(envelope.MappedType, envelope.Content);
                    if (m.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }

                    var result = m.GetMessage();

                    if (
                        MessageBox.Show(this, @"Do you really want to send this message?", @"Sending confirmation",
                                        MessageBoxButtons.YesNo) ==
                        DialogResult.No)
                    {
                        return;
                    }

                    _services.SendCommand((IRecipeCommand)result);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), @"Error");
            }
        }
All Usage Examples Of Audit.Views.ModifyMessage::BindMessage