private Lifestyle GetLifestyle(ObjectLifetime lifestyle)
        {
            switch (lifestyle)
            {
            case ObjectLifetime.Transient:
                return(Lifestyle.Transient);

            case ObjectLifetime.Singleton:
                return(Lifestyle.Singleton);

            default:
                return(Lifestyle.Scoped);
            }
        }
        public void Register <T>(ObjectLifetime lifetime = ObjectLifetime.Transient) where T : class
        {
            switch (lifetime)
            {
            case ObjectLifetime.Transient:
                _container.Register <T>(Lifestyle.Transient);
                break;

            case ObjectLifetime.Singleton:
                _container.Register <T>(Lifestyle.Singleton);
                break;

            default:
                throw new InvalidOperationException("Object lifetime is not supported");
            }
        }
        private void AddMapping(ObjectLifetime lifetime)
        {
            if (_currentTypeMapping == null || _currentTypeMapping.MappedTypeInfo == null)
            {
                ThrowGeneralException();
                return;
            }

            _currentTypeMapping.MappedTypeInfo.Lifetime = lifetime;

            try
            {
                _mappedTypes.Add(_currentTypeMapping.Key, _currentTypeMapping.MappedTypeInfo);
            }
            catch (ArgumentException)
            {
                throw new TypeAlreadyRegisteredException(_currentTypeMapping.Key);
            }
            finally
            {
                _currentTypeMapping = null;
            }
        }
 public DependencyInjector(ObjectLifetime lifestyle)
 {
     _container      = new Container();
     _objectLifetime = lifestyle;
 }