예제 #1
0
        public void TestEventTargetIsSetCorrectlyOnLocal()
        {
            Init(users: 2);

            var    array0 = Arrays[Users[0]];
            YEvent evt    = null;

            array0.EventHandler += (s, e) =>
            {
                evt = e.Event;
            };

            array0.Insert(0, new object[] { "stuff" });
            Assert.AreEqual(array0, evt.Target, "Target property is set correctly");
        }
예제 #2
0
        public void TestEventTargetIsSetCorrectlyOnRemote()
        {
            Init(users: 3);

            var    array0 = Arrays[Users[0]];
            var    array1 = Arrays[Users[1]];
            YEvent evt    = null;

            array0.EventHandler += (s, e) =>
            {
                evt = e.Event;
            };

            array1.Insert(0, new object[] { "stuff" });
            Connector.FlushAllMessages();

            Assert.AreEqual(array0, evt.Target, "Target property is set correctly");

            CompareUsers();
        }
예제 #3
0
파일: AbstractType.cs 프로젝트: alex521/ycs
        /// <summary>
        /// Call event listeners with an event. This will also add an event to all parents
        /// for observeDeep handlers.
        /// </summary>
        internal virtual void CallTypeObservers(Transaction transaction, YEvent evt)
        {
            var type = this;

            while (true)
            {
                if (!transaction.ChangedParentTypes.TryGetValue(type, out var values))
                {
                    values = new List <YEvent>();
                    transaction.ChangedParentTypes[type] = values;
                }

                values.Add(evt);

                if (type._item == null)
                {
                    break;
                }

                type = type._item.Parent as AbstractType;
            }

            InvokeEventHandlers(evt, transaction);
        }
예제 #4
0
파일: AbstractType.cs 프로젝트: alex521/ycs
 internal YEventArgs(YEvent evt, Transaction transaction)
 {
     Event       = evt;
     Transaction = transaction;
 }
예제 #5
0
파일: AbstractType.cs 프로젝트: alex521/ycs
 internal void InvokeEventHandlers(YEvent evt, Transaction transaction)
 {
     EventHandler?.Invoke(this, new YEventArgs(evt, transaction));
 }