本文整理汇总了C#中IListener类的典型用法代码示例。如果您正苦于以下问题:C# IListener类的具体用法?C# IListener怎么用?C# IListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IListener类属于命名空间,在下文中一共展示了IListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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";
}
示例3: Add
public IDisposable Add(IListener t)
{
t.Connected += HandleConnected;
lock(listeners)
listeners.Add(t);
return Disposable.New(o => Remove(o), t);
}
示例4: HeartbeatListener
public HeartbeatListener(IRecurrentCommand heartbeatCommand,
IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IListener innerListener)
{
_heartbeatCommand = heartbeatCommand;
_innerListener = innerListener;
_timer = CreateTimer(backgroundExceptionDispatcher);
}
示例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();
}
}
示例6: ListenersWithoutHandlers
public void ListenersWithoutHandlers()
{
LogManager.SetupLogManager();
var emitter = new Emitter();
var expected = new IListener[] {};
Assert.Equal(expected, emitter.Listeners("foo").ToArray());
}
示例7: RemoveListener
public void RemoveListener(IListener i)
{
if (IsListenerContained(i))
{
listenerList.Remove(i);
}
}
示例8: AddListener
public void AddListener(IListener i)
{
if(!IsListenerContained(i))
{
listenerList.Add(i);
}
}
示例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;
}
示例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;
}
示例11: UnRegister
public void UnRegister(IListener listener)
{
if (listener is AI.AI)
{
UnRegister(listener as AI.AI);
}
}
示例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;
}
示例13: RemoveHandler
public void RemoveHandler(IListener<PropertyChangedEventArgs> eventHandler)
{
if (eventHandler == null)
throw new ArgumentNullException("eventHandler", "eventHandler is null.");
m_Manager.RemoveHandler(eventHandler);
}
示例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;
}
示例15: SerfidCore
public SerfidCore(IListener listener, IFilter filter, IStorage storage, IUser user)
{
_listener = listener;
_filter = filter;
_storage = storage;
_user = user;
}