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

            // When an independent field changes,
            // its dependents become out-of-date.
            MakeDependentsOutOfDate();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Establishes a relationship between this precedent and the currently
        /// updating dependent.
        /// </summary>
        internal void RecordDependent()
        {
            // Get the current dependent.
            Dependent update = Dependent.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();
            }
        }