Example #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");
        }
Example #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();
        }
Example #3
0
        /// <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);
        }
Example #4
0
 internal YEventArgs(YEvent evt, Transaction transaction)
 {
     Event       = evt;
     Transaction = transaction;
 }
Example #5
0
 internal void InvokeEventHandlers(YEvent evt, Transaction transaction)
 {
     EventHandler?.Invoke(this, new YEventArgs(evt, transaction));
 }