/// <summary>
        /// Returns needed Visitor.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ISpotterVisitor GetSpotterVisitor(String name)
        {
            if (_visitors.ContainsKey(name))
            {
                return(_visitors[name]);
            }
            else
            {
                switch (name)
                {
                case "Yahoo/GetListedMessages":
                    var yl = new YahooGetListedMessages();
                    _visitors.Add("Yahoo/GetListedMessages", yl);
                    return(yl);

                case "Yahoo/GetDisplayMessage":
                    var yd = new YahooGetDisplayMessage();
                    _visitors.Add("Yahoo/GetDisplayMessage", yd);
                    return(yd);

                case "Seznam/GetNewMessage":
                    var sn = new SeznamGetNewMessage();
                    _visitors.Add("Seznam/GetNewMessage", sn);
                    return(sn);

                case "Seznam/GetListedMessages":
                    var sl = new SeznamGetListedMessages();
                    _visitors.Add("Seznam/GetListedMessages", sl);
                    return(sl);

                case "Seznam/GetDisplayMessage":
                    var sd = new SeznamGetDisplayMessage();
                    _visitors.Add("Seznam/GetDisplayMessage", sd);
                    return(sd);

                default:
                    throw new ArgumentOutOfRangeException("name", "Unknown spotter visitor " + name);
                }
            }
        }
Example #2
0
        public object applyOn(SpotterJson spotter)
        {
            var root = spotter.GetRoot();
            var mail = new MailMsg();

            if (root.XPathSelectElement("/result/message") != null)
            {
                // there should be only one message in response to display message
                foreach (var msg in root.XPathSelectElements("/result/message/item"))
                {
                    mail.Subject      = msg.XPathSelectElement("header/subject").Value;
                    mail.From         = msg.XPathSelectElement("header/from/email").Value;
                    mail.To           = YahooGetListedMessages.GetAllInArray(msg, "header/to//email", "; ");
                    mail.Cc           = YahooGetListedMessages.GetAllInArray(msg, "header/cc//email", "; ");
                    mail.Bcc          = YahooGetListedMessages.GetAllInArray(msg, "header/bcc//email", "; ");
                    mail.Body         = YahooGetListedMessages.GetAllInArray(msg, "part//text", "");
                    mail.SourceFolder = msg.XPathSelectElement("sourceFolderInfo/name").Value;
                }
            }

            return(mail);
        }