Example #1
0
        /// <summary>
        /// Call this function just before setting the field that this
        /// sentry controls.
        /// </summary>
        /// <remarks>
        /// Any computed fields that depend upon this field will become
        /// out-of-date.
        /// </remarks>
        public void OnSet()
        {
            // Verify that computeds are not changing observables, as that
            // could be a logical circular dependency.
            if (Computed.GetCurrentUpdate() != null)
            {
                Debug.Assert(false, "An observable was changed while updating a computed.");
            }

            // When an observable field changes,
            // its computeds become out-of-date.
            MakeDependentsOutOfDate();
        }
Example #2
0
        /// <summary>
        /// Establishes a relationship between this precedent and the currently
        /// updating dependent.
        /// </summary>
        internal void RecordDependent()
        {
            // Get the current dependent.
            Computed update = Computed.GetCurrentUpdate();

            if (update != null && !Contains(update) && update.AddPrecedent(this))
            {
                if (Insert(update))
                {
                    GainDependent();
                }
            }
            else if (!Any())
            {
                // Though there is no lasting dependency, someone
                // has shown interest.
                GainDependent();
                LoseDependent();
            }
        }