コード例 #1
0
 static async void GetListOfPosts()
 {
     var coninfo = GetDefaultConnectionInfo();
     var client = new MP.Client(coninfo);
     var posts = client.GetRecentPosts(10);
     posts.Wait();
     foreach (var post in posts.Result)
     {
         Console.WriteLine("{0} {1}", post.PostId, post.Title);
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: Injac/MetaWeblogPortable
        static async void GetListOfPosts()
        {
            var coninfo = GetDefaultConnectionInfo();
            var client  = new MP.Client(coninfo);
            var posts   = client.GetRecentPosts(10);

            posts.Wait();
            foreach (var post in posts.Result)
            {
                Console.WriteLine("{0} {1}", post.PostId, post.Title);
            }
        }
コード例 #3
0
        public async Task GetPosts1()
        {

            var con1 = GetBlog1();

            var con2 = new BlogConnectionInfo(
                "http://localhost:14228/test2",
                "http://localhost:14882/test2/metaweblog.axd",
                "test2",
                "admin",
                "admin");


            var client = new Client(con1);

      

            var posts = await client.GetRecentPosts(10000);
            foreach (var p in posts)
            {
                await client.DeletePost(p.PostId);
            }

            posts = await client.GetRecentPosts(10000);
            Assert.AreEqual(0,posts.Count);

            // create and verify a normal post
            string postid = await client.NewPost("P1", "P1Content", null, false, null);
            posts = await client.GetRecentPosts(10000);
            Assert.AreEqual(1,posts.Count);
            Assert.AreEqual(postid, posts[0].PostId);


            // Create another post
            string postid2 = await client.NewPost("P2", "P2Content", null, false, null);
            posts = await client.GetRecentPosts(10000);
            Assert.AreEqual(2, posts.Count);
            Assert.AreEqual(postid2, posts[0].PostId);
            Assert.AreEqual(postid, posts[1].PostId);
            Assert.AreEqual(null, posts[0].PostStatus);


            var firstPost = posts[0];
            string newTitle = firstPost.Title + " Updated";
            await client.EditPost(firstPost.PostId, newTitle , firstPost.Description, null, true);
            var firstPostUpdated = await client.GetPost(firstPost.PostId);
            Assert.AreEqual(newTitle, firstPostUpdated.Title);



        }