本文整理汇总了C#中Emitter.On方法的典型用法代码示例。如果您正苦于以下问题:C# Emitter.On方法的具体用法?C# Emitter.On怎么用?C# Emitter.On使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Emitter
的用法示例。
在下文中一共展示了Emitter.On方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Off
public void Off()
{
var log = LogManager.GetLogger(Global.CallerName());
log.Info("Start");
var emitter = new Emitter();
var calls = new List<object>();
var listener3 = new TestListener3(calls);
emitter.On("foo", listener3);
var listener4 = new TestListener4(calls);
emitter.On("foo", listener4);
emitter.Off("foo", listener4);
emitter.Emit("foo");
var expected = new Object[] {"one"};
CollectionAssert.AreEqual(expected, calls.ToArray());
}
示例2: Off
public void Off()
{
LogManager.SetupLogManager();
var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod());
log.Info("Start");
var emitter = new Emitter();
var calls = new List<object>();
var listener3 = new TestListener3(calls);
emitter.On("foo", listener3);
var listener4 = new TestListener4(calls);
emitter.On("foo", listener4);
emitter.Off("foo", listener4);
emitter.Emit("foo");
var expected = new Object[] {"one"};
Assert.Equal(expected, calls.ToArray());
}
示例3: HasListeners
public void HasListeners()
{
var log = LogManager.GetLogger(Global.CallerName());
log.Info("Start");
var emitter = new Emitter();
var calls = new List<object>();
Assert.AreEqual(false, emitter.HasListeners("foo"));
var listener3 = new TestListener3(calls);
emitter.On("foo", listener3);
Assert.AreEqual(true, emitter.HasListeners("foo"));
}
示例4: Listeners
public void Listeners()
{
var log = LogManager.GetLogger(Global.CallerName());
log.Info("Start");
var emitter = new Emitter();
var calls = new List<object>();
var listener3 = new TestListener3(calls);
emitter.On("foo", listener3);
var expected = new IListener[] {listener3};
Assert.AreEqual(expected.Count(), emitter.Listeners("foo").ToArray().Count());
CollectionAssert.AreEqual(expected, emitter.Listeners("foo").ToArray());
}
示例5: Listeners
public void Listeners()
{
LogManager.SetupLogManager();
var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod());
log.Info("Start");
var emitter = new Emitter();
var calls = new List<object>();
var listener3 = new TestListener3(calls);
emitter.On("foo", listener3);
var expected = new IListener[] {listener3};
Assert.Equal(expected, emitter.Listeners("foo").ToArray());
}
示例6: HasListeners
public void HasListeners()
{
LogManager.SetupLogManager();
var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod());
log.Info("Start");
var emitter = new Emitter();
var calls = new List<object>();
Assert.Equal(false, emitter.HasListeners("foo"));
var listener3 = new TestListener3(calls);
emitter.On("foo", listener3);
Assert.Equal(true, emitter.HasListeners("foo"));
}
示例7: On
public void On()
{
var log = LogManager.GetLogger(Global.CallerName());
log.Info("Start");
var emitter = new Emitter();
var calls = new List<object>();
var listener1 = new TestListener1(calls);
emitter.On("foo", listener1);
var listener2 = new TestListener2(calls);
emitter.On("foo", listener2);
emitter.Emit("foo", 1);
emitter.Emit("bar", 1);
emitter.Emit("foo", 2);
var expected = new Object[] {"one", 1, "two", 1, "one", 2, "two", 2};
CollectionAssert.AreEqual(expected, calls.ToArray());
}
示例8: OffWhenCalledfromEvent
public void OffWhenCalledfromEvent()
{
var log = LogManager.GetLogger(Global.CallerName());
log.Info("Start");
var emitter = new Emitter();
var called = new List<bool>() {false};
var listener5 = new TestListener5(called);
var listener6 = new TestListener6(emitter, listener5);
emitter.On("tobi", listener6);
emitter.Once("tobi", listener5);
emitter.Emit("tobi");
Assert.AreEqual(true, called[0]);
called[0] = false;
emitter.Emit("tobi");
Assert.AreEqual(false, called[0]);
}
示例9: On
public void On()
{
LogManager.SetupLogManager();
var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod());
log.Info("Start");
var emitter = new Emitter();
var calls = new List<object>();
var listener1 = new TestListener1(calls);
emitter.On("foo", listener1);
var listener2 = new TestListener2(calls);
emitter.On("foo", listener2);
emitter.Emit("foo", 1);
emitter.Emit("bar", 1);
emitter.Emit("foo", 2);
var expected = new Object[] {"one", 1, "two", 1, "one", 2, "two", 2};
Assert.Equal(expected, calls.ToArray());
}
示例10: OffWhenCalledfromEvent
public void OffWhenCalledfromEvent()
{
LogManager.SetupLogManager();
var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod());
log.Info("Start");
var emitter = new Emitter();
var called = new List<bool>() {false};
var listener5 = new TestListener5(called);
var listener6 = new TestListener6(emitter, listener5);
emitter.On("tobi", listener6);
emitter.Once("tobi", listener5);
emitter.Emit("tobi");
Assert.Equal(true, called[0]);
called[0] = false;
emitter.Emit("tobi");
Assert.Equal(false, called[0]);
}
示例11: Create
public static IHandle Create(Emitter obj, string ev, IListener fn)
{
obj.On(ev, fn);
return new HandleImpl(obj,ev,fn);
}