Exemple #1
0
        public EventInterrupter Add(EventDispatchQuery eventDispatchQuery, OnEventInterruptCallback onInterruptPredicate)
        {
            Assert.IsFalse(_interrupterDict.ContainsKey(eventDispatchQuery));

            _interrupterDict.Add(eventDispatchQuery, onInterruptPredicate);
            return(this);
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="binderInstanceMap"></param>
        /// <param name="eventInterruptedData"></param>
        /// <returns>trueなら割り込み対象になったイベントを即時送信することを表します。</returns>
        public bool Interrupt(ModelViewBinderInstanceMap binderInstanceMap, EventInterruptedData eventInterruptedData)
        {
            OnEventInterruptCallback matchPredicate = GetInterruptCallback(eventInterruptedData);

            Assert.IsNotNull(matchPredicate);
            var(createdModel, doSendImmediate) = matchPredicate(binderInstanceMap, eventInterruptedData);
            if (createdModel != null)
            {
                if (!binderInstanceMap.BindInstances.ContainsKey(createdModel))
                {
                    Assert.IsTrue(binderInstanceMap.BinderMap.Binders.Any(_b => _b.DoMatch(createdModel)), $"OnEventInterruptCallbackで生成したModelは必ずModelViewBinderInstanceMapに追加されるようにしてください。");
                    binderInstanceMap.Add(createdModel, false, (binderInstance) => {
                        binderInstance.HoldedEventInterruptedData = eventInterruptedData;
                    });
                }
                else
                {
                    binderInstanceMap.BindInstances[createdModel].HoldedEventInterruptedData = eventInterruptedData;
                }
            }
            return(doSendImmediate);
        }