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


C# IMessageContext.Respond方法代码示例

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


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

示例1: Publish

 public void Publish(IMessage message, IMessageContext sender)
 {
     var messageTpye = message.GetType();
     if (handlers.ContainsKey(messageTpye))
     {
         foreach (var handler in handlers[messageTpye])
         {
             dynamic instance = handlerFactory(handler);
             try
             {
                 if (HasResponse(message))
                 {
                     var result = instance.Handle((dynamic)(message.ToPublishedMessage(sender)));
                     sender.Respond(result);
                 }
                 else
                     instance.Handle((dynamic)(message.ToPublishedMessage(sender)));
             }
             catch (Exception ex)
             {
                 sender.ErrorFormat("{0} , {1}", ex.Message, ex.StackTrace);
             }
         }
     }
 }
开发者ID:Elders,项目名称:Skynet,代码行数:25,代码来源:SkynetPublisher.cs

示例2: Respond

 public Task Respond(ChatContextHolder chatContextHolder, IMessageContext context)
 {
     var volumeLevel = ValueConverterHelper.ToInt(ExtractStartsWith(context, "set volume"),10);
     var result = string.Format("volume set to {0}", volumeLevel);
     _textToSpeech.Play(result);
     _volumeSetter.SetVolume(volumeLevel);
     return context.Respond(result);
 }
开发者ID:rolfwessels,项目名称:DarthVaderBuildIndicator,代码行数:8,代码来源:SetVolumeContext.cs

示例3: Respond

 public async Task Respond(ChatContextHolder chatContextHolder, IMessageContext context)
 {
     var oneLiner = RandomTextHelper.OneLiner.Split('.');
     foreach (var message in oneLiner)
     {
         await context.Respond(message);
         await Task.Delay(5000);
     }
 }
开发者ID:rolfwessels,项目名称:DarthVaderBuildIndicator,代码行数:9,代码来源:RandomJokeResponse.cs

示例4: Response

        protected override async Task Response(ChatContextHolder chatContextHolder, IMessageContext context, Server server)
        {
            if (string.IsNullOrEmpty(server.Name))
            {
                await
                    context.Respond(string.Format("Scanning servers."));
            }
            else
            {
                await
                    context.Respond(string.Format("Scanning {0} servers.", server.Name));
            }

            Task.Run(async () =>
            {
                await RunOnBackground(context, server);
            }).FireAndForgetWithLogging();
        }
开发者ID:rolfwessels,项目名称:DarthVaderBuildIndicator,代码行数:18,代码来源:MonitorServerVersionChanges.cs

示例5: Monitor

        private async Task Monitor(IMessageContext context, Server link, List<string> list , bool report)
        {
            for (int i = 0; i < link.ScanCount; i++)
            {
                var serverVersion = await GetVerionForLink(link);
                if (serverVersion == null || list.Contains(serverVersion.ServerName + serverVersion.Version)) continue;
                list.Add(serverVersion.ServerName + serverVersion.Version);
                if (report)
                {
                    await
                        context.Respond(string.Format("{0} now on a new version {1}, released {2} ago.",
                            serverVersion.ServerName, serverVersion.Version,
                            serverVersion.Date.Humanize()));
                }
            }
//            if (!list.Any())
//            {
//                await context.Respond(string.Format("Oops, {0} seems to be down.", link.Uri));
//            }
        }
开发者ID:rolfwessels,项目名称:DarthVaderBuildIndicator,代码行数:20,代码来源:MonitorServerVersionChanges.cs

示例6: Respond

 public Task Respond(ChatContextHolder chatContextHolder, IMessageContext context)
 {
     return Task.Run(() =>
     {
         foreach (LightPin pin in _lights)
         {
             pin.Set(context.Text, _pinManager);
         }
         LightPin[] allOn = _lights.Where(x => x.ContainsSection(context.Text) && x.IsOn(context.Text)).ToArray();
         if (!allOn.Select(x => x.Color).Any())
         {
             context.Respond(string.Format("{0} lights are now off",
                 _lights.Where(x => x.ContainsSection(context.Text))
                     .Select(x => x.Section)
                     .Distinct()
                     .StringJoin()));
         }
         else
         {
             context.Respond(string.Format("{0} {1} lights are now on",
                 allOn.Select(x => x.Section).Distinct().StringJoin(),
                 allOn.Select(x => x.Color).Distinct().StringJoin()));
         }
     });
 }
开发者ID:rolfwessels,项目名称:DarthVaderBuildIndicator,代码行数:25,代码来源:SetIoContext.cs


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