public IEnumerable<SubscriptionItem> ItemsForSubscription(Subscription subscription) { var args = new Dictionary<string, string>() { {"n", "20"}, }; var subscriptionId = System.Uri.EscapeDataString(subscription.Id); var json = httpClient.GET(urls.SubscriptionItems + subscriptionId, args); var serializer = new DataContractJsonSerializer(typeof(JsonSubscriptionItems)); using (var jsonStream = new MemoryStream(Encoding.UTF8.GetBytes(json))) { var container = serializer.ReadObject(jsonStream) as JsonSubscriptionItems; try { subscription.SourceUrl = container.alternate.ElementAt(0).href; } catch (Exception e) { subscription.SourceUrl = "http://www.google.com/reader/"; } return container.items.Select(CreateSubscriptionItem); } }
public void CanParseAtomBasedSubscriptionItems() { var httpClient = new StubHttpClient() { ExpectedUrl = endpointUrls.SubscriptionItems + "feed%2Fid", // feed ID must be URL-encoded ExpectedResponse = @"{ ""items"": [ { ""title"": ""Ajaxian » Front Page"", ""content"": { ""content"": ""Dummy Content"" } } ] }", }; var reader = new ReaderAccount(httpClient, endpointUrls); var subscription = new Subscription(null) { Id = "feed/id", }; Assert.AreEqual("Ajaxian » Front Page", reader.ItemsForSubscription(subscription).ElementAt(0).Title); Assert.AreEqual("Dummy Content", reader.ItemsForSubscription(subscription).ElementAt(0).Content); }
public RenameDialog(Subscription subscription) { InitializeComponent(); SubscriptionName = subscription.Title; Loaded += new RoutedEventHandler((s, e) => { name.SelectAll(); }); }
public void RenameSubscription(Subscription subscription, string newName) { var args = new Dictionary<string, string>() { {"ac", "edit"}, {"s", subscription.Id}, {"t", newName} }; httpClient.POST(urls.EditSubscription, args); }
public void RemoveSubscription(Subscription subscription) { var args = new Dictionary<string, string>() { {"ac", "unsubscribe"}, {"s", subscription.Id}, }; httpClient.POST(urls.EditSubscription, args); }