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


C# Entity.AddEvent方法代码示例

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


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

示例1: AddMultipleEventsOfSameType

        public void AddMultipleEventsOfSameType()
        {
            int eventsFired = 0;

            Entity entity = new Entity();
            entity.Events.CollectionChanged += (o, e) => eventsFired++;

            entity.AddEvent(new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType)));
            entity.AddEvent(new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType)));

            Assert.AreEqual(2, eventsFired);
            Assert.AreEqual(2, entity.Events.Count);
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:13,代码来源:EventTests.cs

示例2: AddLocalEvent

        public void AddLocalEvent()
        {
            bool collectionChanged = false;

            Entity entity = new Entity();
            entity.Events.CollectionChanged += (o, e) => collectionChanged = true;

            Event evt = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType));
            entity.AddEvent(evt);

            Assert.IsTrue(collectionChanged);
            Assert.IsTrue(evt.IsEditable);
            Assert.AreEqual(1, entity.Events.Count);
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:14,代码来源:EventTests.cs

示例3: CannotRemoveReadOnlyEventFromInheritingEntity

        public void CannotRemoveReadOnlyEventFromInheritingEntity()
        {
            bool collectionChanged = false;

            Entity parent = new Entity() { Name = "parent" };

            Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType));
            parentEvent.SetProperty("Trigger", new Value("test"));
            parent.AddEvent(parentEvent);

            Entity child = new Entity();
            child.AddPrototype(parent);

            child.Events.CollectionChanged += (o, e) => collectionChanged = true;

            AbstractEvent childEvent = child.Events.Single();
            child.RemoveEvent(childEvent);

            Assert.IsFalse(collectionChanged);
            Assert.AreEqual(1, child.Events.Count);
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:21,代码来源:EventTests.cs

示例4: CannotSetReadOnlyEventProperty

        public void CannotSetReadOnlyEventProperty()
        {
            Entity parent = new Entity() { Name = "parent" };

            Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType));
            parentEvent.SetProperty("Trigger", new Value("test", true));
            parent.AddEvent(parentEvent);

            Entity child = new Entity();
            child.AddPrototype(parent);

            AbstractProperty childProperty = child.Events.Single().GetProperty("Trigger");
            childProperty.Value = new Value("test2", true);

            Assert.AreEqual("test", childProperty.Value.Reader.GetStrValue());
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:16,代码来源:EventTests.cs

示例5: RemoveReadOnlyEvent

        public void RemoveReadOnlyEvent()
        {
            int eventsFired = 0;

            Entity parent = new Entity() { Name = "parent" };

            Entity child = new Entity();
            child.Events.CollectionChanged += (o, e) => eventsFired++;

            child.AddPrototype(parent);

            Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType));
            parent.AddEvent(parentEvent);
            parent.RemoveEvent(parentEvent);

            Assert.AreEqual(2, eventsFired);
            Assert.AreEqual(0, parent.Events.Count);
            Assert.AreEqual(0, child.Events.Count);
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:19,代码来源:EventTests.cs

示例6: RemoveLocalEvent

        public void RemoveLocalEvent()
        {
            int eventsFired = 0;

            Entity entity = new Entity();
            entity.Events.CollectionChanged += (o, e) => eventsFired++;

            Event evt = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType));
            entity.AddEvent(evt);
            entity.RemoveEvent(evt);

            Assert.AreEqual(2, eventsFired);
            Assert.AreEqual(0, entity.Events.Count);
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:14,代码来源:EventTests.cs

示例7: EventsInheritedFromPrototype

        public void EventsInheritedFromPrototype()
        {
            bool collectionChanged = false;

            Entity parent = new Entity() { Name = "parent" };

            Entity child = new Entity();
            child.Events.CollectionChanged += (o, e) => collectionChanged = true;

            child.AddPrototype(parent);

            Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType));
            parent.AddEvent(parentEvent);

            Assert.IsTrue(collectionChanged);
            Assert.AreEqual(1, parent.Events.Count(x => x.IsEditable));
            Assert.AreEqual(1, child.Events.Count(x => x.IsReadOnly));
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:18,代码来源:EventTests.cs

示例8: EventsInheritedFromAllPrototypes

        public void EventsInheritedFromAllPrototypes()
        {
            int eventsFired = 0;

            Entity parent = new Entity() { Name = "parent" };
            Entity otherParent = new Entity() { Name = "otherParent" };

            Entity child = new Entity();
            child.Events.CollectionChanged += (o, e) => eventsFired++;

            child.AddPrototype(parent);
            child.AddPrototype(otherParent);

            parent.AddEvent(new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType)));
            otherParent.AddEvent(new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType)));

            Assert.AreEqual(2, eventsFired);
            Assert.AreEqual(1, parent.Events.Count(x => x.IsEditable));
            Assert.AreEqual(1, otherParent.Events.Count(x => x.IsEditable));
            Assert.AreEqual(2, child.Events.Count(x => x.IsReadOnly));
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:21,代码来源:EventTests.cs


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