コード例 #1
0
        /// <summary>
        /// Must be called whenever a node value is changed externally, for example when a property node's backing field changes its value.
        /// </summary>
        public void WasChanged(object source)
        {
            if (!Enabled)
            {
                return;
            }

            ReactiveManager.GetNode(source).NotifyChildren();
            (source as IListener)?.Notify();
        }
コード例 #2
0
        /// <summary>
        /// Indicate that the given variable was read. May cause other objects to become dependend on the given variable.
        /// </summary>
        public void WasRead(object source)
        {
            if (!Enabled)
            {
                return;
            }

            if (DependentsEvaluating.Count != 0)
            {
                var weakDependent = DependentsEvaluating.Peek().Dependency;
                ReactiveManager.GetNode(source).Add(weakDependent);
            }
        }
コード例 #3
0
        /// <summary>
        /// Must be called whenever a node value is changed externally, for example when a property node's backing field changes its value.
        /// </summary>
        public void WasChanged(object source)
        {
            if (!Enabled)
            {
                return;
            }

            ReactiveManager.GetNode(source).NotifyChildren(notifyList);
            foreach (IListener toNotify in notifyList)
            {
                toNotify.Notify();
            }
            notifyList.Clear();
            (source as IListener)?.Notify();
        }
コード例 #4
0
        static void WasChangedForChild(Dependency childEdge)
        {
            var child = childEdge.Value;

            if (child == null)
            {
                return;
            }

            var childNode = ReactiveManager.GetNode(child);

            if (childNode.notificationsHad == childEdge.NotificationsHad)             //Determines if the edge is still up-to-date.
            {
                childNode.WasNotified();
                child.Notify();
                childNode.NotifyChildren();
            }
        }
コード例 #5
0
ファイル: ReactiveNode.cs プロジェクト: zs2hx/SmartReactives
        static void WasChangedForChild(ref Chain <IListener> result, IDependency childEdge)
        {
            var child = childEdge.Value;

            if (child == null)
            {
                return;
            }

            var childNode = ReactiveManager.GetNode(child);

            if (childNode.notificationsHad == childEdge.NotificationsHad) //Determines if the edge is still up-to-date.
            {
                childNode.WasNotified();
                result = new Chain <IListener>(child, result);
                childNode.NotifyChildren(ref result);
            }
        }
コード例 #6
0
        /// <summary>
        /// Evaluation of reactive nodes must pass through this method.
        /// </summary>
        public T Evaluate <T>(IListener dependent, Func <T> func)
        {
            if (!Enabled)
            {
                return(func());
            }

            WasRead(dependent);

            var node = ReactiveManager.GetNode(dependent);
            var dependentReference = node.GetDependency(dependent);

            DependentsEvaluating.Push(dependentReference);
            var result = func();

            DependentsEvaluating.Pop();
            return(result);
        }