Ejemplo n.º 1
0
        private void RegisterComponent <T>(ComponentRegistration <T> componentRegistration, LifeStyle lifeStyle, bool isFallback) where T : class
        {
            var lifestyleDescriptor = new LifestyleDescriptor <T>(GetLifestyleType(lifeStyle));

            componentRegistration.AddDescriptor(lifestyleDescriptor);

            if (isFallback)
            {
                componentRegistration = componentRegistration.IsFallback().NamedAutomatically(Guid.NewGuid().ToString());
            }

            container.Register(componentRegistration);
        }
        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);
        }