예제 #1
0
        public bool AddDependent(IOutcome dependentToAdd)
        {
            if (dependentToAdd == null)
            {
                throw new ArgumentNullException(nameof(dependentToAdd));
            }

            var oldFactorSet = affectedOutcomes;

            while (oldFactorSet.Contains(dependentToAdd) == false)
            {
                if (IsValid)
                {
                    var newFactorSet = oldFactorSet.Add(dependentToAdd);

                    //- TODO : Test this and make sure if this is invalidated the dependent still gets a notification.
                    if (TryCompareExchange(ref affectedOutcomes, newFactorSet, oldFactorSet, out oldFactorSet))
                    {
                        return(true);
                    }
                }
                else
                {
                    //- TODO : This code is replicated in section where the CasualEvent tries to add dependencies.
                    dependentToAdd.Invalidate(this);
                    return(false);
                }
            }

            return(false);
        }
예제 #2
0
        public bool AddDependent(IOutcome dependentOutcome)
        {
            //- TODO : This code is replicated in section where CasualEvent tries to add dependencies.
            if (dependentOutcome.IsValid)
            {
                dependentOutcome.Invalidate(this);
            }

            return(false);
        }