public XElement Serialize(MessageQuestion messageQuestion, string elementName = "question")
        {
            messageQuestion.ThrowIfNull("messageQuestion");
            elementName.ThrowIfNull("elementName");

            return new XElement(
                elementName,
                messageQuestion.Answers.Select(arg => MessageAnswerSerializer.Instance.Serialize(arg)),
                new XAttribute("prompt", messageQuestion.Prompt),
                new XAttribute("questionForegroundColor", ColorSerializer.Instance.Serialize(messageQuestion.QuestionForegroundColor)),
                new XAttribute("unselectedAnswerForegroundColor", ColorSerializer.Instance.Serialize(messageQuestion.UnselectedAnswerForegroundColor)),
                new XAttribute("selectedAnswerForegroundColor", ColorSerializer.Instance.Serialize(messageQuestion.SelectedAnswerForegroundColor)),
                new XAttribute("selectedAnswerBackgroundColor", ColorSerializer.Instance.Serialize(messageQuestion.SelectedAnswerBackgroundColor)));
        }
        public byte[] Serialize(MessageQuestion messageQuestion)
        {
            messageQuestion.ThrowIfNull("messageQuestion");

            var serializer = new CompactSerializer();

            serializer[0] = Encoding.UTF8.GetBytes(messageQuestion.Prompt);
            serializer[1] = ColorSerializer.Instance.Serialize(messageQuestion.QuestionForegroundColor);
            serializer[2] = ColorSerializer.Instance.Serialize(messageQuestion.UnselectedAnswerForegroundColor);
            serializer[3] = ColorSerializer.Instance.Serialize(messageQuestion.SelectedAnswerForegroundColor);
            serializer[4] = ColorSerializer.Instance.Serialize(messageQuestion.SelectedAnswerBackgroundColor);

            var answerSerializer = new CompactSerializer();
            int index = 0;

            foreach (MessageAnswer answer in messageQuestion.Answers)
            {
                answerSerializer[index++] = MessageAnswerSerializer.Instance.Serialize(answer);
            }

            serializer[5] = answerSerializer.Serialize();

            return serializer.Serialize();
        }