Ejemplo n.º 1
0
        /// <summary>
        /// Converts the message.
        /// </summary>
        /// <param name="xElement">The executable element.</param>
        /// <returns>Message.</returns>
        public static Message ConvertMessage(XElement xElement)
        {
            Message message = null;

            if (xElement != null && xElement.Name.LocalName == nodeName_Xml)
            {
                string type = xElement.GetValue(nodeName_MessageType);

                if (!string.IsNullOrWhiteSpace(type))
                {
                    MessageType messageType;
                    if (Enum.TryParse <MessageType>(type, true, out messageType))
                    {
                        switch (messageType)
                        {
                        case MessageType.Text:
                            message = new ContentMessage();
                            break;

                        case MessageType.Event:
                            message = new EventMessage();
                            break;

                        case MessageType.Location:
                            message = new GeographyMessage();
                            break;

                        default:
                            break;
                        }

                        if (message != null)
                        {
                            message.FillObjectData(xElement);
                        }
                    }
                }
            }

            return(message);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts the message.
        /// </summary>
        /// <param name="xElement">The executable element.</param>
        /// <returns>Message.</returns>
        public static Message ConvertMessage(XElement xElement)
        {
            Message message = null;

            if (xElement != null && xElement.Name.LocalName == nodeName_Xml)
            {
                string type = xElement.GetValue(nodeName_MessageType);

                if (!string.IsNullOrWhiteSpace(type))
                {
                    MessageType messageType;
                    if (Enum.TryParse<MessageType>(type, true, out messageType))
                    {
                        switch (messageType)
                        {
                            case MessageType.Text:
                                message = new ContentMessage();
                                break;
                            case MessageType.Event:
                                message = new EventMessage();
                                break;
                            case MessageType.Location:
                                message = new GeographyMessage();
                                break;
                            default:
                                break;
                        }

                        if (message != null)
                        {
                            message.FillObjectData(xElement);
                        }
                    }
                }
            }

            return message;
        }