• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IListener的典型用法代码示例。如果您正苦于以下问题:C# IListener类的具体用法?C# IListener怎么用?C# IListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IListener类属于命名空间,在下文中一共展示了IListener类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Handle

        public string Handle(string input, Match match, IListener listener)
        {
            var query = match.Groups[1].Value;
            var tl = new TorrentLeech();
            var results = tl.Search(query);
            var res = string.Empty;
            var count = 0;

            foreach(var result in results)
            {
                if (count > 7)
                    break;
                res += count++ + ": " + result.Title + ": " + result.Size + " MB" + Environment.NewLine;
            }

            Brain.Pipe.ListenNext((input2, match2, listener2) =>
                                      {
                                          if (match2.Value == "cancel" || match2.Value == "none" || match2.Value == "nevermind")
                                              return "Cancelled";

                                          var index = -1;
                                          int.TryParse(match2.Groups[1].Value, out index);
                                          if (index == -1 || index >= results.Count)
                                              return "Cancelled";

                                          var selected = results[index];
                                          selected.Download();
                                          return "Downloading: " + selected.Friendly;
                                      }, "cancel|none|nevermind", @"download (\d+)");
                    return res;
        }
开发者ID:taimur38,项目名称:Yaar,代码行数:31,代码来源:TorrentCommand.cs


示例2: Handle

 public IEnumerable<string> Handle(string input, Match match, IListener listener)
 {
     var tl = new TorrentLeech();
     var movies = tl.GetEntries(TorrentLeech.Movies).Distinct().Take(20).ToArray();
     var names = movies.Select(o => o.Friendly).ToArray();
     Brain.Pipe.ListenOnce((i, m, l) =>
         {
             var movie = m.Groups[1].Value;
             var entry = movies.FirstOrDefault(o => o.Friendly.ToLower().Contains(movie));
             if(entry == null)
                 return;
             if(!entry.Download())
             {
                 Brain.Pipe.ListenNext((s, match1, listener1) =>
                     {
                         if (match1.Value == "yes")
                         {
                             entry.Download(true);
                             listener1.Output(Speech.Yes.Parse());
                             listener1.Output("I shall redownload it.");
                             return;
                         }
                         listener1.Output(Speech.Yes.Parse());
                         listener1.Output("I won't redownload it.");
                     }, "yes", "no");
                 l.Output("You've already downloaded that sir. Do you want to redownload it?");
             }
             else
             {
                 l.Output("Downloading " + entry.Friendly + "...");
             }
         }, "download (.+)");
     yield return "Here are the latest films. Do you want to download any of them?";
     yield return string.Join(", ", names) + "\r\n";
 }
开发者ID:csyolen,项目名称:Jarvis,代码行数:35,代码来源:MoviesCommand.cs


示例3: Add

 public IDisposable Add(IListener t)
 {
     t.Connected += HandleConnected;
     lock(listeners)
         listeners.Add(t);
     return Disposable.New(o => Remove(o), t);
 }
开发者ID:stangelandcl,项目名称:Actors,代码行数:7,代码来源:Listeners.cs


示例4: HeartbeatListener

 public HeartbeatListener(IRecurrentCommand heartbeatCommand,
     IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IListener innerListener)
 {
     _heartbeatCommand = heartbeatCommand;
     _innerListener = innerListener;
     _timer = CreateTimer(backgroundExceptionDispatcher);
 }
开发者ID:rafaelmtz,项目名称:azure-webjobs-sdk,代码行数:7,代码来源:HeartbeatListener.cs


示例5: ConnectionManager

        private ConnectionManager(IListener listener, IServiceDiscovery serviceDiscovery, TimeSpan? serviceDiscoveryPeriod)
        {
            this.remoteServices = new Dictionary<ServiceUri, PerformanceStatistics>();
            this.Listener = listener;
            if (serviceDiscovery != null)
            {
                this.serviceDiscovery = serviceDiscovery;
                this.serviceDiscoveryPeriod = serviceDiscoveryPeriod ?? new TimeSpan(hours: 0, minutes: 0, seconds: 5);
                this.serviceDiscoveryThread = new Thread(() =>
                {
                    while (!this.shouldStop)
                    {
                        var availableServices = this.serviceDiscovery.GetPerformanceStatistics();
                        lock (this.remoteServicesLock)
                        {
                            this.remoteServices.Clear();
                            foreach (var service in availableServices.Keys)
                            {
                                if (this.Listener==null || !service.Equals(this.Listener.CallbackUri))
                                {
                                    this.remoteServices.Add(service, availableServices[service]);
                                }
                            }
                        }

                        Thread.Sleep(this.serviceDiscoveryPeriod);
                    }
                });

                this.serviceDiscoveryThread.Start();
            }
        }
开发者ID:pbazydlo,项目名称:bluepath,代码行数:32,代码来源:ConnectionManager.cs


示例6: ListenersWithoutHandlers

 public void ListenersWithoutHandlers()
 {
     LogManager.SetupLogManager();
     var emitter = new Emitter();
     var expected = new IListener[] {};
     Assert.Equal(expected, emitter.Listeners("foo").ToArray());
 }
开发者ID:Quobject,项目名称:EngineIoClientDotNet,代码行数:7,代码来源:EmitterTests.cs


示例7: RemoveListener

 public void RemoveListener(IListener i)
 {
     if (IsListenerContained(i))
     {
         listenerList.Remove(i);
     }
 }
开发者ID:duoduo3369,项目名称:javaExercise,代码行数:7,代码来源:Tower.cs


示例8: AddListener

 public void AddListener(IListener i)
 {
     if(!IsListenerContained(i))
     {
         listenerList.Add(i);
     }
 }
开发者ID:duoduo3369,项目名称:javaExercise,代码行数:7,代码来源:Tower.cs


示例9: Handle

 public IEnumerable<string> Handle(string input, Match match, IListener listener)
 {
     var output = ScheduleTicker.Instance.Tasks
         .Where(o => o.DateTime < DateTime.Now.AddDays(2))
         .Select(task => task.Description + " at " + task.DateTime.ToShortTimeString());
     return output;
 }
开发者ID:csyolen,项目名称:Jarvis,代码行数:7,代码来源:ScheduleListCommand.cs


示例10: Handle

 public string Handle(string input, Match match, IListener listener)
 {
     var subject = match.Groups[1].Value.Trim();
     var search = new Search(subject);
     Brain.RunnableManager.Runnable = new ProcessRunnable(search.Link);
     return search.Description;
 }
开发者ID:taimur38,项目名称:Yaar,代码行数:7,代码来源:SearchCommand.cs


示例11: UnRegister

 public void UnRegister(IListener listener)
 {
     if (listener is AI.AI)
     {
         UnRegister(listener as AI.AI);
     }
 }
开发者ID:quziqin,项目名称:NervDog2DGameEngine,代码行数:7,代码来源:AIManager.cs


示例12: Bot

        private int runCount = 0; // number of times run has been called

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="Bot"/> class.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="userInteraction">The user interaction manager..</param>
        /// <param name="console">The console.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="listener">The listener.</param>
        /// <param name="pluginHandler">The plugin handler.</param>
        /// <param name="moduleLoader">The module loader.</param>
        /// <param name="authorization">The authorization manager.</param>
        public Bot(
            Client client, 
            IUserInteraction userInteraction, 
            IConsole console, 
            IBotSettings settings, 
            IListener listener, 
            IPluginHandler pluginHandler,
            IModuleLoader moduleLoader,
            IAuthorization authorization)
        {
            Guard.Against(client.IsNull(), "client");
            Guard.Against(userInteraction.IsNull(), "userInteraction");
            Guard.Against(console.IsNull(), "console");
            Guard.Against(settings.IsNull(), "settings");
            Guard.Against(listener.IsNull(), "listener");
            Guard.Against(pluginHandler.IsNull(), "pluginHandler");
            Guard.Against(moduleLoader.IsNull(), "moduleLoader");
            Guard.Against(authorization.IsNull(), "authorization");

            this.client = client;
            this.userInteraction = userInteraction;
            this.console = console;
            this.settings = settings;
            this.listener = listener;
            this.pluginHandler = pluginHandler;
            this.moduleLoader = moduleLoader;
            this.authorization = authorization;
            this.SessionStart = DateTime.Now;
        }
开发者ID:JonHaywood,项目名称:Oberon,代码行数:46,代码来源:Bot.cs


示例13: RemoveHandler

        public void RemoveHandler(IListener<PropertyChangedEventArgs> eventHandler)
        {
            if (eventHandler == null)
                throw new ArgumentNullException("eventHandler", "eventHandler is null.");

            m_Manager.RemoveHandler(eventHandler);
        }
开发者ID:docevaad,项目名称:Anchor,代码行数:7,代码来源:WeakNotifier.cs


示例14: ResultSetColumnMapping

 public ResultSetColumnMapping(IResultSetColumnMapping other, IListener listener, IPolicies policies, ICompilerMessageBuilder messageProvider)
 {
     if(ReferenceEquals(other, null))
         throw new ArgumentNullException(nameof(other));
     this.ColumnName = other.ColumnName;
     this.PropertyName = other.PropertyName;
 }
开发者ID:AlexeyEvlampiev,项目名称:Alenosoft,代码行数:7,代码来源:ResultSetColumnMapping.cs


示例15: SerfidCore

 public SerfidCore(IListener listener, IFilter filter, IStorage storage, IUser user)
 {
     _listener = listener;
     _filter = filter;
     _storage = storage;
     _user = user;
 }
开发者ID:sonyas12,项目名称:GitHubVS2013,代码行数:7,代码来源:SerfidCore.cs


示例16: LcdpServer

        public LcdpServer(ILcdpPacketSerializer lcdpPacketSerializer, IListener listener, IForwarder forwarder, IResolver resolver)
        {
            this.lcdpPacketSerializer = lcdpPacketSerializer;

            this.listener = listener;
            this.forwarder = forwarder;

            this.messages = new ConcurrentDictionary<string, LcdpMessage>();

            this.ChunkExpirationTimeMilliseconds = 5000;

            this.compressors = new Dictionary<byte, ICompressor>();
            this.serializers = new Dictionary<byte, ISerializer>();

            for(byte b = 0; b < byte.MaxValue; ++b)
            {
                ICompressor compressor = resolver.Resolve<ICompressor>(b.ToString());
                if (compressor != null)
                {
                    compressors[b] = compressor;
                }

                ISerializer serializer = resolver.Resolve<ISerializer>(b.ToString());
                if (serializer != null)
                {
                    serializers[b] = serializer;
                }
            }
        }
开发者ID:DropZone,项目名称:LogC,代码行数:29,代码来源:LcdpServer.cs


示例17: Handle

        public void Handle(string input, IListener listener)
        {
            if(input == null) return;
            input = input.ToLower();

            if (_next != null)
            {
                var clone = (DynamicCommand) _next.Clone();
                _next = null;
                if(clone.Execute(input, listener))
                    return;
            }
            _next = null;
            foreach (var c in _permanent.ToArray())
            {
                if(c.Execute(input, listener))
                    break;
            }

            foreach (var c in _once.ToArray())
            {
                if(c.Execute(input, listener))
                    _once.Remove(c);

            }
        }
开发者ID:csyolen,项目名称:Jarvis,代码行数:26,代码来源:Pipe.cs


示例18: Parse

 private void Parse(string q, List<FileInfo> videos, IListener listener)
 {
     videos = videos.Where(o => o.Name.ToLower().Contains(q)).ToList();
     if(videos.Count > 1)
     {
         listener.Output("Which one of these should I play?");
         listener.Output(string.Join("\r\n", videos.Select(o => o.Name.ToLower())));
         Brain.Pipe.ListenNext((input, match, listener1) => Parse(input, videos, listener), "(.+)");
     }
     if (videos.Count == 0)
     {
         listener.Output("I could not find that video sir.");
     }
     if (videos.Count == 1)
     {
         var video = videos.First();
         Process.Start(video.FullName);
         var name = video.Name.Replace(".", " ").Trim().RegexRemove(video.Extension);
         name = name.RegexReplace(@"s(\d+)", "Season $1 ");
         name = name.RegexReplace(@"e(\d+)", "Episode $1 ");
         name = name.Trim().RemoveExtraSpaces();
         name = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(name.ToLower());
         listener.Output("Playing " + name);
     }
 }
开发者ID:csyolen,项目名称:Jarvis,代码行数:25,代码来源:VideoCommand.cs


示例19: Handle

 public string Handle(string input, Match match, IListener listener)
 {
     var output = ScheduleTicker.Instance.Tasks
         .Where(o => o.DateTime < DateTime.Now.AddDays(2))
         .Aggregate("", (current, task) => current + (task.Description + " at " + task.DateTime.ToShortTimeString() + Environment.NewLine));
     return output.Trim();
 }
开发者ID:taimur38,项目名称:Yaar,代码行数:7,代码来源:ScheduleListCommand.cs


示例20: Handle

 public string Handle(string input, Match match, IListener listener)
 {
     var text = match.Groups[1].Value;
     //test code
     ToastView.Create(text, "taimur38", false);
     return text;
 }
开发者ID:taimur38,项目名称:Yaar,代码行数:7,代码来源:SayCommand.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ILiteralNode类代码示例发布时间:2022-05-24
下一篇:
C# IList类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap