Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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;
            }
        }
Esempio n. 3
0
        /// <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);
                }
            }
        }
Esempio n. 4
0
        /// <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);
                }
            }
        }