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


C# IUserSession.GetDirectMessagesSent方法代码示例

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


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

示例1: DoDMTest

        public async Task<bool> DoDMTest(IUserSession session, List<int> testSeq)
        {
            var successStatus = true;
            try
            {
                // 1
                long dmid = 0;
                if (testSeq.Contains(1))
                {
                    ConsoleOutput.PrintMessage("3.1 DirectMessages\\GetDirectMessages", ConsoleColor.Gray);
                    var directmessages1 = await session.GetDirectMessages();

                    if (directmessages1.OK)
                    {
                        dmid = directmessages1.ToList()[0].Id;
                        foreach (var x in directmessages1)
                        {
                            ConsoleOutput.PrintMessage(
                                String.Format("From: {0} // Message: {1}", x.SenderScreenName, x.Text ));
                        }
                    }
                    else
                        successStatus = false;
                }

                // 2
                if (testSeq.Contains(2))
                {
                    ConsoleOutput.PrintMessage("3.2 DirectMessages\\GetDirectMessagesSent", ConsoleColor.Gray);
                    var directmessages2 = await session.GetDirectMessagesSent();

                    if (directmessages2.OK)
                    {
                        foreach (var x in directmessages2)
                        {
                            ConsoleOutput.PrintMessage(
                                String.Format("To: {0} // Message: {1}", x.Recipient.ScreenName, x.Text));
                        }
                    }
                    else
                        successStatus = false;
                }

                // 3
                if (testSeq.Contains(3))
                {
                    ConsoleOutput.PrintMessage("3.3 DirectMessages\\GetDirectMessageSingle", ConsoleColor.Gray);
                    var directmessages3 = await session.GetDirectMessageSingle(dmid);

                    if (directmessages3.OK)
                    {
                            ConsoleOutput.PrintMessage(
                                String.Format("From: {0} // Message: {1}", directmessages3.SenderScreenName, directmessages3.Text));
                    }
                    else
                        successStatus = false;
                }

                // 4
                if (testSeq.Contains(4))
                {
                    ConsoleOutput.PrintMessage("3.4 DirectMessages\\SendDirectMessage", ConsoleColor.Gray);
                    var directmessages4 =
                        await session.SendDirectMessage("livefire test of boxkite.twitter please ignore", "neilfinn");

                    if (directmessages4.OK)
                    {
                        ConsoleOutput.PrintMessage(
                            String.Format("From: {0} // Message: {1}", directmessages4.SenderScreenName, directmessages4.Text));
                    }
                    else
                        successStatus = false;
                }
            }
            catch (Exception e)
            {
                ConsoleOutput.PrintError(e.ToString());
                return false;
            }
            return successStatus;
        }
开发者ID:gerryaobrien,项目名称:BoxKite.Twitter,代码行数:81,代码来源:03DirectMessagesLiveFireTests.cs

示例2: DoDMTest

        public async Task<bool> DoDMTest(IUserSession session, List<int> testSeq)
        {
            var successStatus = true;
            try
            {
                // 1
                long dmid = 0;
                if (testSeq.Contains(1))
                {
                    ConsoleOutput.PrintMessage("3.1 DirectMessages\\GetDirectMessages", ConsoleColor.Gray);
                    var directmessages1 = await session.GetDirectMessages();

                    if (directmessages1.OK)
                    {
                        dmid = directmessages1.ToList()[0].Id;
                        foreach (var x in directmessages1)
                        {
                            ConsoleOutput.PrintMessage(
                                string.Format("ID: {2} // From: {0} // Message: {1}", x.SenderScreenName, x.Text, x.Id ));
                        }
                    }
                    else
                        successStatus = false;
                }

                // 2
                if (testSeq.Contains(2))
                {
                    ConsoleOutput.PrintMessage("3.2 DirectMessages\\GetDirectMessagesSent", ConsoleColor.Gray);
                    var directmessages2 = await session.GetDirectMessagesSent();

                    if (directmessages2.OK)
                    {
                        foreach (var x in directmessages2)
                        {
                            ConsoleOutput.PrintMessage(
                                String.Format("To: {0} // Message: {1}", x.Recipient.ScreenName, x.Text));
                        }
                    }
                    else
                        successStatus = false;
                }

                // 3
                if (testSeq.Contains(3))
                {
                    ConsoleOutput.PrintMessage("3.3 DirectMessages\\GetDirectMessageSingle", ConsoleColor.Gray);
                    var directmessages3 = await session.GetDirectMessageSingle(dmid);

                    if (directmessages3.OK)
                    {
                            ConsoleOutput.PrintMessage(
                                String.Format("From: {0} // Message: {1}", directmessages3.SenderScreenName, directmessages3.Text));
                    }
                    else
                        successStatus = false;
                }

                // 4
                if (testSeq.Contains(4))
                {
                    ConsoleOutput.PrintMessage("3.4 DirectMessages\\SendDirectMessage", ConsoleColor.Gray);
                    var directmessages4 =
                        await session.SendDirectMessage("livefire test of boxkite.twitter please ignore", "nickhodgeau");

                    if (directmessages4.OK)
                    {
                        ConsoleOutput.PrintMessage(
                            String.Format("From: {0} // Message: {1}", directmessages4.SenderScreenName, directmessages4.Text));
                    }
                    else
                        successStatus = false;
                }

                // 5
                if (testSeq.Contains(5))
                {
                    ConsoleOutput.PrintMessage("3.5 DirectMessages\\SendDirectMessage > 140 chars", ConsoleColor.Gray);

                    var directmessage5contents = "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";

                    var directmessages5 =
                        await session.SendDirectMessage("realnickhodge", directmessage5contents);

                    if (directmessages5.OK)
                    {
                        ConsoleOutput.PrintMessage(
                            String.Format("From: {0} // Length: {1} // Message: {2}", directmessages5.SenderScreenName,
                                directmessage5contents.Length, directmessages5.Text));
                    }
                    else
                    {
                        ConsoleOutput.PrintError(
                            String.Format("Error: {0}", directmessages5.twitterControlMessage.twitter_error_message));
                        successStatus = false;
                    }
                }

            }
            catch (Exception e)
//.........这里部分代码省略.........
开发者ID:nickhodge,项目名称:BoxKite.Twitter,代码行数:101,代码来源:03DirectMessagesLiveFireTests.cs


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