当前位置: 首页>>代码示例>>C#>>正文


C# TwitterContext.DestroyStatus方法代码示例

本文整理汇总了C#中LinqToTwitter.TwitterContext.DestroyStatus方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterContext.DestroyStatus方法的具体用法?C# TwitterContext.DestroyStatus怎么用?C# TwitterContext.DestroyStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinqToTwitter.TwitterContext的用法示例。


在下文中一共展示了TwitterContext.DestroyStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DestroyStatus_Throws_On_Null_ID

        public void DestroyStatus_Throws_On_Null_ID()
        {
            string id = string.Empty;
            var authMock = new Mock<ITwitterAuthorizer>();
            var execMock = new Mock<ITwitterExecute>();
            execMock.SetupGet(exec => exec.AuthorizedClient).Returns(authMock.Object);
            execMock.Setup(exec =>
                exec.PostToTwitter(
                    It.IsAny<string>(),
                    It.IsAny<Dictionary<string, string>>(),
                    It.IsAny<Func<string, Status>>()))
                .Returns(SingleStatusResponse);
            var ctx = new TwitterContext(authMock.Object, execMock.Object, "", "");

            var ex = Assert.Throws<ArgumentException>(() => ctx.DestroyStatus(id));

            Assert.Equal("id", ex.ParamName);
        }
开发者ID:CheyPMK,项目名称:linqtotwitter,代码行数:18,代码来源:StatusExtensionsTests.cs

示例2: DestroyStatusDemo

        /// <summary>
        /// shows how to delete a status
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void DestroyStatusDemo(TwitterContext twitterCtx)
        {
            var status = twitterCtx.DestroyStatus("280433519057068033");

            Console.WriteLine(
                "(" + status.StatusID + ")" +
                "[" + status.User.ID + "]" +
                status.User.Name + ", " +
                status.Text + ", " +
                status.CreatedAt);
        }
开发者ID:CheyPMK,项目名称:linqtotwitter,代码行数:15,代码来源:StatusDemos.cs

示例3: DestroyStatus_Sets_ID

        public void DestroyStatus_Sets_ID()
        {
            const string Id = "184835136037191681";
            string expectedStatusID = "184835136037191681";
            var authMock = new Mock<ITwitterAuthorizer>();
            var execMock = new Mock<ITwitterExecute>();
            execMock.SetupGet(exec => exec.AuthorizedClient).Returns(authMock.Object);
            execMock.Setup(exec =>
                exec.PostToTwitter(
                    It.IsAny<string>(),
                    It.IsAny<Dictionary<string, string>>(),
                    It.IsAny<Func<string, Status>>()))
                .Returns(SingleStatusResponse);
            var ctx = new TwitterContext(authMock.Object, execMock.Object, "", "");

            Status actual = ctx.DestroyStatus(Id);

            Assert.Equal(expectedStatusID, actual.StatusID);
        }
开发者ID:CheyPMK,项目名称:linqtotwitter,代码行数:19,代码来源:StatusExtensionsTests.cs

示例4: EraseTweetsAction

        //We start multiple actions in parallel to delete tweets
        void EraseTweetsAction(TwitterContext ctx, CancellationToken cancelToken)
        {
            int nextTweetID = getNextTweetIDSync();

            #if DEBUG
            Random rnd = new Random();
            #endif

            //Are we done?
            while (nextTweetID != Int32.MinValue)
            {
                //We can't cancel here, we have already fetched a new ID and if we cancel here it will never be deteled

                Tweet tweet = tweets[nextTweetID];

                //Clear Tweets logic here
                try
                {
            #if DEBUG
                    Thread.Sleep(sleepFakeWaitMilliseconds);
                    if (rnd.Next() % 3 == 0)    // Simulate error
                    {
                        throw new ArgumentNullException();
                    }
                    else
                    {
                        throw new Exception("Sorry, that page does not exist");
                    }
            #else
                    Status ret = ctx.DestroyStatus(tweet.ID);
            #endif
                    tweet.Status = STATUS_DELETED;
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("Sorry, that page does not exist"))
                        tweet.Status = STATUS_NOT_FOUND;
                    else if (ex.Message.Contains("You may not delete another user's status"))
                        tweet.Status = STATUS_NOT_ALLOWED;
                    else
                    {
                        tweet.Status = STATUS_ERROR;
                        var tmp = new tweetTJson() { created_at = tweet.Date.ToString("yyyy-MM-dd H:m:s zzz"), id_str = tweet.ID, text = tweet.Text };

                        lock (_lockerNotDeletedTweetsLst)
                        {
                            notDeletedTweets.Add(tmp);
                        }
                    }
                }

                onDeletingTweetUIUpdate(tweet);

                //We cancel once a tweet is completely handeled, we make sure not to request for a new one
                if (cancelToken.IsCancellationRequested)
                    return;

                nextTweetID = getNextTweetIDSync();
            }
        }
开发者ID:usarmyraver24,项目名称:Twitter-Archive-Eraser,代码行数:61,代码来源:DeleteTweets.xaml.cs


注:本文中的LinqToTwitter.TwitterContext.DestroyStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。