/// <summary> /// /// </summary> /// <see cref="ValueRouterBase{TValue}.OnCalculateRoutedSource()"/> protected override IValueRouter <TValue> OnCalculateRoutedSource() { var stradegyFunc = this.GetStradegyFunc(); IValueRouter <TValue> result = this; var currentValue = this.MyValue; foreach (var mediatorData in this.GetMediators() .Select(m => new { RouterObject = m, Value = m.RoutedValue, })) { var computedValue = stradegyFunc(currentValue, mediatorData.Value); if (!EqualityComparer <TValue> .Default.Equals(currentValue, computedValue)) { currentValue = computedValue; result = mediatorData.RouterObject; } } return(result); }
/// <summary> /// Initialisiert diese Shell. /// </summary> /// <param name="context">Der Kontext der die Daten um Initialisieren enthält.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="context" /> ist <see langword="null" />. /// </exception> /// <exception cref="InvalidOperationException"> /// Diese Shell wurde bereits initialisiert. /// </exception> /// <exception cref="ObjectDisposedException"> /// Diese Shell wurde bereits verworfen. /// </exception> public void Inititialize(IModuleShellInitializeContext context) { context.ThrowIfParamIsNull(() => context); lock (this._SYNC_ROOT) { this.ThrowIfDisposed(); if (this.IsInitialized) { throw new InvalidOperationException(); } this.InnerFunctionLogger = new DelegateLogger(); this.Logger = new AggregateLogger(); this.Logger.Add(this.InnerFunctionLogger); this.State = new EnumValueRouter <TrafficLightState>(); this.ModuleCompositionCatalog = new AggregateCatalog(); this.ReloadModulesInner(); this.IsInitialized = true; } }
/// <summary> /// /// </summary> /// <see cref="IValueRouter{TValue}.RemoveObserver(IValueRouter{TValue})" /> public void RemoveObserver(IValueRouter <TValue> router) { if (router == null) { throw new ArgumentNullException("router"); } lock (this._SYNC) { if (this._OBSERVERS.Remove(router)) { router.RemoveMediator(this); } } }
/// <summary> /// /// </summary> /// <see cref="IValueRouter{TValue}.RemoveMediator(IValueRouter{TValue})" /> public void RemoveMediator(IValueRouter <TValue> router) { if (router == null) { throw new ArgumentNullException("router"); } lock (this._SYNC) { if (this._MEDIATORS.Remove(router)) { router.PropertyChanged -= this.Router_PropertyChanged; router.RemoveObserver(this); } } }