コード例 #1
0
ファイル: ReaderAccount.cs プロジェクト: igstan/nemira
        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);
            }
        }
コード例 #2
0
ファイル: GoogleReaderTest.cs プロジェクト: igstan/nemira
        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);
        }
コード例 #3
0
ファイル: RenameDialog.xaml.cs プロジェクト: igstan/nemira
        public RenameDialog(Subscription subscription)
        {
            InitializeComponent();

            SubscriptionName = subscription.Title;

            Loaded += new RoutedEventHandler((s, e) => {
                name.SelectAll();
            });
        }
コード例 #4
0
ファイル: ReaderAccount.cs プロジェクト: igstan/nemira
        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);
        }
コード例 #5
0
ファイル: ReaderAccount.cs プロジェクト: igstan/nemira
        public void RemoveSubscription(Subscription subscription)
        {
            var args = new Dictionary<string, string>()
            {
                {"ac", "unsubscribe"},
                {"s", subscription.Id},
            };

            httpClient.POST(urls.EditSubscription, args);
        }