Ejemplo n.º 1
0
        /// <inheritdoc />
        public IStashboxContainer RegisterDecorator <TFrom, TTo>(Action <DecoratorConfigurator <TFrom, TTo> > configurator = null)
            where TFrom : class
            where TTo : class, TFrom
        {
            this.ThrowIfDisposed();
            var decoratorConfigurator = new DecoratorConfigurator <TFrom, TTo>(typeof(TFrom), typeof(TTo));

            configurator?.Invoke(decoratorConfigurator);
            return(this.RegisterInternal(decoratorConfigurator, true));
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public IStashboxContainer RegisterDecorator <TTo>(Action <DecoratorConfigurator <TTo, TTo> > configurator = null)
            where TTo : class
        {
            this.ThrowIfDisposed();
            var type = typeof(TTo);
            var decoratorConfigurator = new DecoratorConfigurator <TTo, TTo>(type, type);

            configurator?.Invoke(decoratorConfigurator);
            decoratorConfigurator.AsImplementedTypes();
            return(this.RegisterInternal(decoratorConfigurator, true));
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        public IStashboxContainer RegisterDecorator <TFrom>(Type typeTo, Action <DecoratorConfigurator <TFrom, TFrom> > configurator = null)
            where TFrom : class
        {
            this.ThrowIfDisposed();
            Shield.EnsureNotNull(typeTo, nameof(typeTo));

            var decoratorConfigurator = new DecoratorConfigurator <TFrom, TFrom>(typeof(TFrom), typeTo);

            configurator?.Invoke(decoratorConfigurator);

            if (!decoratorConfigurator.TypeMapIsValid(out var error))
            {
                throw new InvalidRegistrationException(decoratorConfigurator.ImplementationType, error);
            }

            return(this.RegisterInternal(decoratorConfigurator, true));
        }