Ejemplo n.º 1
0
        public MessagePartDtoModelV1(MessagePartModel part)
        {
            if (part == null)
            {
                throw new ArgumentNullException("part");
            }

            IsHighlight = part.IsHighlight;
            if (part is TextMessagePartModel)
            {
                var textPart = (TextMessagePartModel)part;
                Type            = "Text";
                ForegroundColor = textPart.ForegroundColor;
                BackgroundColor = textPart.BackgroundColor;
                Underline       = textPart.Underline;
                Bold            = textPart.Bold;
                Italic          = textPart.Italic;
                Text            = textPart.Text;
            }
            if (part is UrlMessagePartModel)
            {
                var urlPart = (UrlMessagePartModel)part;
                Type = "URL";
                Url  = urlPart.Url;
                Text = urlPart.Text;
            }
            if (part is ImageMessagePartModel)
            {
                var imagePart = (ImageMessagePartModel)part;
                Type            = "Image";
                ImageFileName   = imagePart.ImageFileName;
                AlternativeText = imagePart.AlternativeText;
            }
        }
Ejemplo n.º 2
0
        public MessageModel ToMessage()
        {
            var msg = new MessageModel()
            {
                MessageType = this.MessageType,
                TimeStamp   = this.TimeStamp
            };

            foreach (var msgPart in MessageParts)
            {
                MessagePartModel part = null;
                switch (msgPart.Type)
                {
                case "Text":
                    var textPart = new TextMessagePartModel()
                    {
                        ForegroundColor = msgPart.ForegroundColor,
                        BackgroundColor = msgPart.BackgroundColor,
                        Underline       = msgPart.Underline,
                        Bold            = msgPart.Bold,
                        Italic          = msgPart.Italic,
                        Text            = msgPart.Text
                    };
                    part = textPart;
                    break;

                case "URL":
                    var urlPart = new UrlMessagePartModel()
                    {
                        Url  = msgPart.Url,
                        Text = msgPart.Text
                    };
                    part = urlPart;
                    break;

                case "Image":
                    var imagePart = new ImageMessagePartModel()
                    {
                        ImageFileName   = msgPart.ImageFileName,
                        AlternativeText = msgPart.AlternativeText
                    };
                    part = imagePart;
                    break;
                }
                if (part == null)
                {
                    continue;
                }
                part.IsHighlight = msgPart.IsHighlight;
                msg.MessageParts.Add(part);
            }
            return(msg);
        }
Ejemplo n.º 3
0
        public MessagePartDtoModelV1(MessagePartModel part)
        {
            if (part == null) {
                throw new ArgumentNullException("part");
            }

            IsHighlight = part.IsHighlight;
            if (part is TextMessagePartModel) {
                var textPart = (TextMessagePartModel) part;
                Type = "Text";
                ForegroundColor = textPart.ForegroundColor;
                BackgroundColor = textPart.BackgroundColor;
                Underline = textPart.Underline;
                Bold = textPart.Bold;
                Italic = textPart.Italic;
                Text = textPart.Text;
            }
            if (part is UrlMessagePartModel) {
                var urlPart = (UrlMessagePartModel) part;
                Type = "URL";
                Url = urlPart.Url;
                Text = urlPart.Text;
            }
            if (part is ImageMessagePartModel) {
                var imagePart = (ImageMessagePartModel) part;
                Type = "Image";
                ImageFileName = imagePart.ImageFileName;
                AlternativeText = imagePart.AlternativeText;
            }
        }