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


C# EventManager.Subscribe方法代码示例

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


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

示例1: PubTwiceSubTwice

 public void PubTwiceSubTwice()
 {
     IEventManager mgr = new EventManager();
     mgr.Subscribe(typeof(string), BasicListener);
     mgr.Subscribe(typeof(string), BasicListener);
     mgr.Publish("Some Basic String 1");
     mgr.Publish("Some Basic String 2");
     Assert.AreEqual(4, _heardcount);
 }
开发者ID:marcinczekaj,项目名称:v1-jira-integration,代码行数:9,代码来源:EventSystemTester.cs

示例2: MultipleCalls

 public void MultipleCalls()
 {
     IEventManager mgr = new EventManager();
     mgr.Subscribe(typeof(string), BasicListener);
     mgr.Subscribe(typeof(string), BasicListener);
     mgr.Publish("Some Basic String");
     Assert.AreEqual(2, _heardcount);
     Assert.AreEqual("Some Basic String", _lastheard);
 }
开发者ID:marcinczekaj,项目名称:v1-jira-integration,代码行数:9,代码来源:EventSystemTester.cs

示例3: 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);
        }
开发者ID:marcinczekaj,项目名称:v1-jira-integration,代码行数:28,代码来源:ChangeSetWriterTester.cs

示例4: StatsManager

    // Use this for initialization
    public StatsManager()
    {
        eventManager = ServiceManager.Instance.GetService<EventManager>(ServiceType.EventManager);
        eventManager.Register(WeightChange);
        eventManager.Register(NewWeight);

        eventManager.Subscribe(WeightChange, OnWeightChange);
    }
开发者ID:NaterTots,项目名称:WeightLossQuest,代码行数:9,代码来源:StatsManager.cs

示例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);
        }
开发者ID:marcinczekaj,项目名称:v1-jira-integration,代码行数:14,代码来源:EventSystemTester.cs

示例6: Awake

 public void Awake()
 {
     eventManager = ServiceManager.Instance.GetService<EventManager>(ServiceType.EventManager);
     eventManager.Subscribe(StatsManager.NewWeight, OnNewWeight);
     eventManager.Register(NewTargetWeightEvent);
 }
开发者ID:NaterTots,项目名称:WeightLossQuest,代码行数:6,代码来源:LevelManager.cs

示例7: 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);
        }
开发者ID:marcinczekaj,项目名称:v1-jira-integration,代码行数:35,代码来源:ChangeSetWriterTester.cs

示例8: 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);
 }
开发者ID:marcinczekaj,项目名称:v1-jira-integration,代码行数:13,代码来源:ChangeSetWriterTester.cs

示例9: 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));
        }
开发者ID:marcinczekaj,项目名称:v1-jira-integration,代码行数:23,代码来源:ChangeSetWriterTester.cs

示例10: 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);
 }
开发者ID:marcinczekaj,项目名称:v1-jira-integration,代码行数:10,代码来源:ChangeSetWriterTester.cs


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