示例#1
0
        public void SynchronizeLateRightToLeftOnly <TValue>(Action <TLeft, TValue> leftSetter, Expression <Func <TRight, TValue> > rightSelector)
        {
            if (rightSelector == null)
            {
                throw new ArgumentNullException("rightSelector");
            }
            if (leftSetter == null)
            {
                throw new ArgumentNullException("leftSetter");
            }

            SynchronizationJobs.Add(new RightToLeftPropertySynchronizationJob <TLeft, TRight, TValue>(leftSetter, rightSelector, false));
        }
示例#2
0
        public void SynchronizeLeftToRightOnly <TValue>(Expression <Func <TLeft, TValue> > leftSelector, Action <TRight, TValue> rightSetter)
        {
            if (leftSelector == null)
            {
                throw new ArgumentNullException("leftSelector");
            }
            if (rightSetter == null)
            {
                throw new ArgumentNullException("rightSetter");
            }

            SynchronizationJobs.Add(new LeftToRightPropertySynchronizationJob <TLeft, TRight, TValue>(leftSelector, rightSetter, true));
        }
示例#3
0
        public void Synchronize <TValue>(Expression <Func <TLeft, TValue> > leftSelector, Expression <Func <TRight, TValue> > rightSelector, Expression <Func <TLeft, TRight, bool> > guard)
        {
            var job = new PropertySynchronizationJob <TLeft, TRight, TValue>(leftSelector, rightSelector, false);

            if (guard == null)
            {
                SynchronizationJobs.Add(job);
            }
            else
            {
                SynchronizationJobs.Add(new BothGuardedSynchronizationJob <TLeft, TRight>(job, guard));
            }
        }
示例#4
0
        internal void Synchronize(SynchronizationComputation <TLeft, TRight> computation, SynchronizationDirection direction, ISynchronizationContext context)
        {
            var dependencies = computation.Dependencies;

            foreach (var job in SynchronizationJobs.Where(j => !j.IsEarly))
            {
                var dependency = job.Perform(computation, direction, context);
                if (dependency != null)
                {
                    dependencies.Add(dependency);
                }
            }
        }
示例#5
0
        internal void InitializeOutput(SynchronizationComputation <TLeft, TRight> computation)
        {
            var context      = computation.SynchronizationContext;
            var dependencies = computation.Dependencies;

            foreach (var job in SynchronizationJobs.Where(j => j.IsEarly))
            {
                var dependency = job.Perform(computation, context.Direction, context);
                if (dependency != null)
                {
                    dependencies.Add(dependency);
                }
            }
        }
示例#6
0
        public void MarkInstantiatingFor(SynchronizationRuleBase synchronizationRule, Expression <Func <TLeft, bool> > leftPredicate = null, Expression <Func <TRight, bool> > rightPredicate = null)
        {
            if (synchronizationRule == null)
            {
                throw new ArgumentNullException("synchronizationRule");
            }

            if (!synchronizationRule.LeftType.IsAssignableFrom(typeof(TLeft)))
            {
                throw new ArgumentException("The left types do not conform. The left type of the current rule must be an assignable of the given synchronization rules left type.", "synchronizationRule");
            }
            if (!synchronizationRule.RightType.IsAssignableFrom(typeof(TRight)))
            {
                throw new ArgumentException("The right types do not conform. The right type of the current rule must be an assignable of the given synchronization rules right type.", "synchronizationRule");
            }
            leftPredicate  = SimplifyPredicate(leftPredicate);
            rightPredicate = SimplifyPredicate(rightPredicate);

            ObservingFunc <TLeft, bool> leftFunc = ObservingFunc <TLeft, bool> .FromExpression(leftPredicate);

            ObservingFunc <TRight, bool> rightFunc = ObservingFunc <TRight, bool> .FromExpression(rightPredicate);

            if (leftFunc != null)
            {
                LeftToRight.MarkInstantiatingFor(synchronizationRule.LTR, leftFunc.Evaluate);
                SynchronizationJobs.Add(new LeftInstantiationMonitorJob <TLeft, TRight>(leftFunc));
            }
            else
            {
                LeftToRight.MarkInstantiatingFor(synchronizationRule.LTR);
            }
            if (rightFunc != null)
            {
                RightToLeft.MarkInstantiatingFor(synchronizationRule.RTL, rightFunc.Evaluate);
                SynchronizationJobs.Add(new RightInstantiationMonitorJob <TLeft, TRight>(rightFunc));
            }
            else
            {
                RightToLeft.MarkInstantiatingFor(synchronizationRule.RTL);
            }
        }
示例#7
0
        public void SynchronizeRightToLeftOnly <TValue>(Action <TLeft, TValue> leftSetter, Expression <Func <TRight, TValue> > rightSelector, Expression <Func <TRight, bool> > guard)
        {
            if (rightSelector == null)
            {
                throw new ArgumentNullException("rightSelector");
            }
            if (leftSetter == null)
            {
                throw new ArgumentNullException("leftSetter");
            }

            guard = SimplifyPredicate(guard);

            var job = new RightToLeftPropertySynchronizationJob <TLeft, TRight, TValue>(leftSetter, rightSelector, false);

            if (guard == null)
            {
                SynchronizationJobs.Add(job);
            }
            else
            {
                SynchronizationJobs.Add(new RightGuardedSynchronizationJob <TLeft, TRight>(job, guard));
            }
        }
示例#8
0
 public void SynchronizeOpaque(Func <TLeft, TRight, SynchronizationDirection, ISynchronizationContext, IDisposable> action)
 {
     SynchronizationJobs.Add(new OpaqueSynchronizationJob <TLeft, TRight>(action));
 }
示例#9
0
 public void Synchronize <TValue>(Expression <Func <TLeft, TValue> > leftSelector, Expression <Func <TRight, TValue> > rightSelector)
 {
     SynchronizationJobs.Add(new PropertySynchronizationJob <TLeft, TRight, TValue>(leftSelector, rightSelector, true));
 }