Exemple #1
0
        public Feed(FeedUser user, IList <FeedNotification> notifications)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            if (notifications == null)
            {
                throw new ArgumentNullException(nameof(notifications));
            }

            User          = user;
            Notifications = notifications;
        }
Exemple #2
0
        public Feed GetFeed(DateTime?since)
        {
            string url = "notify-get-updates";

            if (since.HasValue)
            {
                url += "?since=" + Uri.EscapeDataString(since.Value.ToString(DateTimeFormat));
            }

            string response = DoRequest(url);

            JObject obj;

            using (var reader = new StringReader(response))
                using (var json = new JsonTextReader(reader))
                {
                    json.DateParseHandling  = DateParseHandling.None;
                    json.FloatParseHandling = FloatParseHandling.Decimal;

                    obj = JObject.Load(json);
                }

            FeedUser user = null;
            IList <FeedNotification> notifications = null;

            foreach (var entry in obj)
            {
                switch (entry.Key)
                {
                case "user":
                    user = ParseFeedUser((JObject)entry.Value);
                    break;

                case "feed":
                    notifications = ParseFeedNotifications((JArray)entry.Value);
                    break;
                }
            }

            return(new Feed(user, notifications));
        }