public static string SerializeToText(MessageFormData messageData)
        {
            var sb = new StringBuilder();
            MessageFormDataTextSerializer.SerializeToText(messageData, sb);

            return sb.ToString();
        }
        public MessageForm(MessageFormType type, string message, string caption, ExceptionInfo exceptionInfo, MessageBoxButtons buttons, string[] attachedFilePathes, MessageFormSettings settingsOverrides)
        {
            var defaultSettings = DefaultMessageFormSettingsProvider.GetDefaultMessageFormSettings();
            _settings = MessageFormSettings.Merge(settingsOverrides, defaultSettings);
            _messageData = CreateMessageFormData(type, message, caption, exceptionInfo, _settings);
            _buttons = buttons;
            _attachedFilePathes = attachedFilePathes;

            InitializeComponent();

            this.Text = _messageData.Title;
            this.SetMessage(_messageData.DisplayText);
            this.SetIcon(type);

            switch (_messageData.MessageType)
            {
                case MessageFormType.Error:
                case MessageFormType.Warning:
                    this.ShowErrorDetails();
                    break;
            }

            this.InitializeButtons(type, buttons);
            this.ResizeView(_messageData.DisplayText);
        }
            public static void SerializeToText(MessageFormData messageData, StringBuilder sb)
            {
                if (messageData == null)
                {
                    return;
                }

                sb.Append(DELIMITER_LINE);
                sb.AppendLine();
                sb.Append(messageData.Title);
                sb.AppendLine();
                sb.Append(DELIMITER_LINE);
                sb.AppendLine();
                sb.Append(messageData.DisplayText);
                sb.AppendLine();
                sb.Append(DELIMITER_LINE);
                sb.AppendLine();
                sb.AppendLine();
                sb.Append("Техническая информация:");
                sb.AppendLine();
                MessageFormData.SerializeToXml(messageData, sb);
                sb.AppendLine();
                sb.Append(DELIMITER_LINE);
                sb.AppendLine();
            }
        public static string SerializeToShortText(MessageFormData messageData)
        {
            var sb = new StringBuilder();

            MessageFormDataShortTextSerializer.SerializeToShortText(messageData, sb);

            return(sb.ToString());
        }
        public static void SerializeToXml(MessageFormData data, StringBuilder sb)
        {
            if (data == null)
            {
                return;
            }

            var writer = new StringWriter(sb);
            var serializer = new XmlSerializer(typeof(MessageFormData));
            serializer.Serialize(writer, data);
        }
        public static void SerializeToXml(MessageFormData data, StringBuilder sb)
        {
            if (data == null)
            {
                return;
            }

            var writer     = new StringWriter(sb);
            var serializer = new XmlSerializer(typeof(MessageFormData));

            serializer.Serialize(writer, data);
        }
        public static string SerializeToXml(MessageFormData data)
        {
            if (data == null)
            {
                return "";
            }

            var writer = new StringWriter();
            var serializer = new XmlSerializer(typeof(MessageFormData));
            serializer.Serialize(writer, data);

            return writer.ToString();
        }
            public static void SerializeToShortText(MessageFormData messageData, StringBuilder sb)
            {
                if (messageData == null)
                {
                    return;
                }

                sb.AppendLine(SerializeValue(messageData.DisplayText));
                sb.AppendLine(SECTION_DELIMITER);

                sb.AppendLine("Техническая информация:");
                SerializeShortEnvironmentInfoToStringBuilder(messageData.EnvironmentInfo, sb);
                SerializeShortExceptionInfoToStringBuilder(messageData.ExceptionInfo, sb);
            }
        public static string SerializeToXml(MessageFormData data)
        {
            if (data == null)
            {
                return("");
            }

            var writer     = new StringWriter();
            var serializer = new XmlSerializer(typeof(MessageFormData));

            serializer.Serialize(writer, data);

            return(writer.ToString());
        }
Exemple #10
0
        private static void TraceMessageData(MessageFormType type, MessageFormData messageData)
        {
            if (messageData == null)
            {
                return;
            }

            if (type == MessageFormType.Error)
            {
                var messageDataXml = MessageFormData.SerializeToXml(messageData);
                Trace.TraceError(messageDataXml);
            }
            else if (type == MessageFormType.Warning)
            {
                var messageDataXml = MessageFormData.SerializeToXml(messageData);
                Trace.TraceWarning(messageDataXml);
            }
        }
Exemple #11
0
        private static MessageFormData CreateMessageFormData(MessageFormType type, string message, string caption, ExceptionInfo exceptionInfo, MessageFormSettings settingsOverrides)
        {
            var messageData = new MessageFormData
            {
                MessageType     = type,
                EnvironmentInfo = EnvironmentInfo.GetEnvironmentInfo(),
                ExceptionInfo   = exceptionInfo,
            };

            if (!string.IsNullOrEmpty(message))
            {
                messageData.DisplayText = message;
            }
            else
            {
                if (exceptionInfo != null && !string.IsNullOrEmpty(exceptionInfo.Message))
                {
                    messageData.DisplayText = exceptionInfo.Message;
                }
                else
                {
                    messageData.DisplayText = settingsOverrides.DefaultDisplayText;
                }
            }

            if (!string.IsNullOrEmpty(caption))
            {
                messageData.Title = caption;
            }
            else
            {
                messageData.Title = messageData.EnvironmentInfo.ProductName;
            }

            return(messageData);
        }
 public static void SerializeToShortText(MessageFormData messageData, StringBuilder sb)
 {
     MessageFormDataShortTextSerializer.SerializeToShortText(messageData, sb);
 }
        private static void TraceMessageData(MessageFormType type, MessageFormData messageData)
        {
            if (messageData == null)
            {
                return;
            }

            if (type == MessageFormType.Error)
            {
                var messageDataXml = MessageFormData.SerializeToXml(messageData);
                Trace.TraceError(messageDataXml);
            }
            else if (type == MessageFormType.Warning)
            {
                var messageDataXml = MessageFormData.SerializeToXml(messageData);
                Trace.TraceWarning(messageDataXml);
            }
        }
        private static MessageFormData CreateMessageFormData(MessageFormType type, string message, string caption, ExceptionInfo exceptionInfo, MessageFormSettings settingsOverrides)
        {
            var messageData = new MessageFormData
            {
                MessageType = type,
                EnvironmentInfo = EnvironmentInfo.GetEnvironmentInfo(),
                ExceptionInfo = exceptionInfo,
            };

            if (!string.IsNullOrEmpty(message))
            {
                messageData.DisplayText = message;
            }
            else
            {
                if (exceptionInfo != null && !string.IsNullOrEmpty(exceptionInfo.Message))
                {
                    messageData.DisplayText = exceptionInfo.Message;
                }
                else
                {
                    messageData.DisplayText = settingsOverrides.DefaultDisplayText;
                }
            }

            if (!string.IsNullOrEmpty(caption))
            {
                messageData.Title = caption;
            }
            else
            {
                messageData.Title = messageData.EnvironmentInfo.ProductName;
            }

            return messageData;
        }
Exemple #15
0
        private void CopyToClipboard()
        {
            var text = MessageFormData.SerializeToText(_messageData);

            Clipboard.SetText(text);
        }
Exemple #16
0
 private void ShowErrorDetails()
 {
     txtErrorDetails.Text = MessageFormData.SerializeToXml(_messageData);
 }
 public static void SerializeToText(MessageFormData messageData, StringBuilder sb)
 {
     MessageFormDataTextSerializer.SerializeToText(messageData, sb);
 }
            public static void SerializeToText(MessageFormData messageData, StringBuilder sb)
            {
                if (messageData == null)
                {
                    return;
                }

                sb.Append(DELIMITER_LINE);
                sb.AppendLine();
                sb.Append(messageData.Title);
                sb.AppendLine();
                sb.Append(DELIMITER_LINE);
                sb.AppendLine();
                sb.Append(messageData.DisplayText);
                sb.AppendLine();
                sb.Append(DELIMITER_LINE);
                sb.AppendLine();
                sb.AppendLine();
                sb.Append("Техническая информация:");
                sb.AppendLine();
                MessageFormData.SerializeToXml(messageData, sb);
                sb.AppendLine();
                sb.Append(DELIMITER_LINE);
                sb.AppendLine();
            }
            public static void SerializeToShortText(MessageFormData messageData, StringBuilder sb)
            {
                if (messageData == null)
                {
                    return;
                }

                sb.AppendLine(SerializeValue(messageData.DisplayText));
                sb.AppendLine(SECTION_DELIMITER);

                sb.AppendLine("Техническая информация:");
                SerializeShortEnvironmentInfoToStringBuilder(messageData.EnvironmentInfo, sb);
                SerializeShortExceptionInfoToStringBuilder(messageData.ExceptionInfo, sb);
            }