本文整理汇总了C#中EventManager.Publish方法的典型用法代码示例。如果您正苦于以下问题:C# EventManager.Publish方法的具体用法?C# EventManager.Publish怎么用?C# EventManager.Publish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventManager
的用法示例。
在下文中一共展示了EventManager.Publish方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PubTwiceSubOnce
public void PubTwiceSubOnce()
{
IEventManager mgr = new EventManager();
mgr.Subscribe(typeof(string), BasicListener);
mgr.Publish("Some Basic String 1");
mgr.Publish("Some Basic String 2");
Assert.AreEqual(2, _heardcount);
}
示例2: ChangeSetAlreadyExists
public void ChangeSetAlreadyExists()
{
IEventManager mgr = new EventManager();
var svc = new TestChangeSetWriterService();
svc.StubCentral.Services.BeforeSave += Services_BeforeSave;
svc.Initialize(ConfigNoLink, mgr, null);
mgr.Subscribe(typeof(LogMessage), LogMessageListener);
IList<string> references = new List<string>();
references.Add("S-1000");
mgr.Publish(new ChangeSetInfo("Author", "Message", new List<string>(), "5", referenceDate, references));
IAttributeDefinition changesetreferencedef = svc.StubCentral.MetaModel.GetAttributeDefinition("ChangeSet.Reference");
IAttributeDefinition changesetprimaryworkitemsdef = svc.StubCentral.MetaModel.GetAttributeDefinition("ChangeSet.PrimaryWorkitems");
IAttributeDefinition changesetnamedef = svc.StubCentral.MetaModel.GetAttributeDefinition("ChangeSet.Name");
IAttributeDefinition changesetdescriptionref = svc.StubCentral.MetaModel.GetAttributeDefinition("ChangeSet.Description");
Assert.AreEqual(1, _lastsaved.Count);
Asset beforesave = _lastsaved[0].Assets[0];
Assert.AreEqual(GetReferenceChangeSetNameDef(), beforesave.GetAttribute(changesetnamedef).Value);
Assert.AreEqual("Message", beforesave.GetAttribute(changesetdescriptionref).Value);
Assert.AreEqual("5", beforesave.GetAttribute(changesetreferencedef).Value);
Assert.AreEqual(svc.StubCentral.Services.GetOid("Story:1004"), beforesave.GetAttribute(changesetprimaryworkitemsdef).ValuesList[0]);
//Assert.AreEqual(1,_logmessages.Count);
Assert.AreEqual("Using existing Change Set: 5 (ChangeSet:1003:105)", _logmessages[0].Message);
}
示例3: Foo
public void Foo()
{
var reader = new TestableSvnReaderService();
IEventManager eventManager = new EventManager();
reader.Initialize(Config, eventManager, null);
eventManager.Publish(new SvnReaderHostedService.SvnReaderIntervalSync());
}
示例4: Basic
public void Basic()
{
IEventManager mgr = new EventManager();
mgr.Subscribe(typeof(string),BasicListener);
mgr.Publish("Some Basic String");
Assert.AreEqual(1,_heardcount);
Assert.AreEqual("Some Basic String",_lastheard);
}
示例5: UnsubscribeTest
public void UnsubscribeTest()
{
const string shouldReceive = "This should be received";
const string shouldNotReceive = "We aren't going to get this one";
IEventManager mgr = new EventManager();
mgr.Subscribe(typeof(string), BasicListener);
mgr.Publish(shouldReceive);
mgr.Unsubscribe(typeof(string), BasicListener);
mgr.Publish(shouldNotReceive);
Assert.AreEqual(_heardcount, 1);
Assert.AreEqual(_lastheard, shouldReceive);
}
示例6: SaveChangeSetWithLink
public void SaveChangeSetWithLink()
{
IEventManager mgr = new EventManager();
var svc = new TestChangeSetWriterService();
svc.StubCentral.Services.BeforeSave += Services_BeforeSave;
svc.Initialize(ConfigWithLink, mgr, null);
mgr.Subscribe(typeof(LogMessage), LogMessageListener);
IList<string> references = new List<string>();
references.Add("S-1000");
mgr.Publish(new ChangeSetInfo("Author", "Message", new List<string>(), "8", referenceDate, references));
Assert.AreEqual(2, _lastsaved.Count);
Asset savedchangeset = _lastsaved[0].Assets[0];
IAttributeDefinition changesetreferencedef = svc.StubCentral.MetaModel.GetAttributeDefinition("ChangeSet.Reference");
IAttributeDefinition changesetprimaryworkitemsdef = svc.StubCentral.MetaModel.GetAttributeDefinition("ChangeSet.PrimaryWorkitems");
IAttributeDefinition changesetnamedef = svc.StubCentral.MetaModel.GetAttributeDefinition("ChangeSet.Name");
IAttributeDefinition changesetdescriptionref = svc.StubCentral.MetaModel.GetAttributeDefinition("ChangeSet.Description");
Assert.AreEqual(GetReferenceChangeSetNameDef(), savedchangeset.GetAttribute(changesetnamedef).Value);
Assert.AreEqual("Message", savedchangeset.GetAttribute(changesetdescriptionref).Value);
Assert.AreEqual("8", savedchangeset.GetAttribute(changesetreferencedef).Value);
Assert.AreEqual(svc.StubCentral.Services.GetOid("Story:1004"), savedchangeset.GetAttribute(changesetprimaryworkitemsdef).ValuesList[0]);
Asset savedlink = _lastsaved[1].Assets[0];
IAttributeDefinition linknamedef = svc.StubCentral.MetaModel.GetAttributeDefinition("Link.Name");
IAttributeDefinition linkurldef = svc.StubCentral.MetaModel.GetAttributeDefinition("Link.URL");
IAttributeDefinition linkonmenudef = svc.StubCentral.MetaModel.GetAttributeDefinition("Link.OnMenu");
Assert.AreEqual("ChangeSet: 8", savedlink.GetAttribute(linknamedef).Value);
Assert.AreEqual("http://server/8", savedlink.GetAttribute(linkurldef).Value);
Assert.AreEqual(true, savedlink.GetAttribute(linkonmenudef).Value);
}
示例7: ChangeSetNoWorkitems
public void ChangeSetNoWorkitems()
{
IEventManager mgr = new EventManager();
var svc = new TestChangeSetWriterService();
svc.Initialize(ConfigNoLink, mgr, null);
mgr.Subscribe(typeof(LogMessage), LogMessageListener);
IList<string> references = new List<string>();
references.Add("TK-1111");
mgr.Publish(new ChangeSetInfo("Author", "Message", new List<string>(), "7", DateTime.Now, references));
Assert.AreEqual(2, _logmessages.Count);
Assert.AreEqual("No Stories or Defects related to reference: TK-1111", _logmessages[0].Message);
Assert.AreEqual("No Change Set References. Ignoring Change Set: 7", _logmessages[1].Message);
}
示例8: ChangeSetNoReferences_AlwasyCreate
public void ChangeSetNoReferences_AlwasyCreate()
{
IEventManager mgr = new EventManager();
var svc = new TestChangeSetWriterService();
svc.StubCentral.Services.BeforeSave += Services_BeforeSave;
svc.Initialize(ConfigAlwaysCreate, mgr, null);
mgr.Subscribe(typeof(LogMessage), LogMessageListener);
mgr.Publish(new ChangeSetInfo("Author", "Message", new List<string>(), "6", referenceDate, new List<string>()));
IAttributeDefinition changesetreferencedef = svc.StubCentral.MetaModel.GetAttributeDefinition("ChangeSet.Reference");
IAttributeDefinition changesetprimaryworkitemsdef = svc.StubCentral.MetaModel.GetAttributeDefinition("ChangeSet.PrimaryWorkitems");
IAttributeDefinition changesetnamedef = svc.StubCentral.MetaModel.GetAttributeDefinition("ChangeSet.Name");
IAttributeDefinition changesetdescriptionref = svc.StubCentral.MetaModel.GetAttributeDefinition("ChangeSet.Description");
Assert.AreEqual(1, _lastsaved.Count);
Asset beforesave = _lastsaved[0].Assets[0];
Assert.AreEqual(GetReferenceChangeSetNameDef(), beforesave.GetAttribute(changesetnamedef).Value);
Assert.AreEqual("Message", beforesave.GetAttribute(changesetdescriptionref).Value);
Assert.AreEqual("6", beforesave.GetAttribute(changesetreferencedef).Value);
Assert.IsNull(beforesave.GetAttribute(changesetprimaryworkitemsdef));
}
示例9: ChangeSetNoReferences
public void ChangeSetNoReferences()
{
IEventManager mgr = new EventManager();
var svc = new TestChangeSetWriterService();
svc.Initialize(ConfigNoLink, mgr, null);
mgr.Subscribe(typeof(LogMessage), LogMessageListener);
mgr.Publish(new ChangeSetInfo("Author", "Message", new List<string>(), "6", DateTime.Now, new List<string>()));
Assert.AreEqual(1, _logmessages.Count);
Assert.AreEqual("No Change Set References. Ignoring Change Set: 6", _logmessages[0].Message);
}