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)); }
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)); }
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)); } }
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); } } }
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); } } }
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); } }
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)); } }
public void SynchronizeOpaque(Func <TLeft, TRight, SynchronizationDirection, ISynchronizationContext, IDisposable> action) { SynchronizationJobs.Add(new OpaqueSynchronizationJob <TLeft, TRight>(action)); }
public void Synchronize <TValue>(Expression <Func <TLeft, TValue> > leftSelector, Expression <Func <TRight, TValue> > rightSelector) { SynchronizationJobs.Add(new PropertySynchronizationJob <TLeft, TRight, TValue>(leftSelector, rightSelector, true)); }