Exemplo n.º 1
0
        public static ComponentRegistration <T> ConfigIsDefaultImpl <T>(this ComponentRegistration <T> cr, Type type)
            where T : class
        {
            if (type.HasAttribute <DefaultImplementation>())
            {
                return(cr.IsDefault());
            }

            return(cr);
        }
        private void Configure <TService>(ComponentRegistration <TService> conf, string name, bool isDefault, bool isFallback, Action <ComponentRegistration <TService> > configuration)
            where TService : class
        {
            if (isDefault)
            {
                conf.IsDefault();
            }
            if (isFallback)
            {
                conf.IsFallback();
            }

            if (!string.IsNullOrWhiteSpace(name))
            {
                conf.Named(name);
            }

            configuration?.Invoke(conf);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Registers the transient.
        /// </summary>
        /// <typeparam name="TService">The type of the service.</typeparam>
        /// <param name="name">The name.</param>
        /// <param name="isDefault">if set to <c>true</c> [is default].</param>
        /// <returns></returns>
        public override IIocManager RegisterTransient <TService>(string name = null, bool isDefault = false)
        {
            ComponentRegistration <TService> config = Component.For <TService>().LifestyleTransient();

            if (isDefault)
            {
                config.IsDefault();
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                Container.Register(config);
            }
            else
            {
                Container.Register(config.Named(name));
            }
            return(this);
        }
 public static ComponentRegistration <TService> IsDecorator <TService>(this ComponentRegistration <TService> registration) where TService : class
 => registration.IsDefault();