public IIocContainer Register <TFrom, TTo>(InstanceLifetimeType lifetime)
     where TFrom : class where TTo : class, TFrom
 {
     _container.Register <TFrom, TTo>(ConvertLifetimeType(lifetime));
     _onRegistrationsFinnished += () => DiagnosticWarningDisposableTransientHandler(typeof(TFrom));
     return(this);
 }
        public void Register(Assembly assembly, Func <Type, bool> whereFunc, InstanceLifetimeType lifetime)
        {
            var registrations = assembly.GetExportedTypes().Where(type => type?.GetInterfaces().Any() ?? false).Where(whereFunc).Select(type => new { Service = type?.GetInterfaces().Last(), Implementation = type });

            foreach (var reg in registrations)
            {
                _container.Register(reg.Service, reg.Implementation, ConvertLifetimeType(lifetime));
                _onRegistrationsFinnished += () => DiagnosticWarningDisposableTransientHandler(reg.Service);
            }
        }
        private static Lifestyle ConvertLifetimeType(InstanceLifetimeType lifetime)
        {
            switch (lifetime)
            {
            case InstanceLifetimeType.Scoped:
                return(Lifestyle.Scoped);

            case InstanceLifetimeType.SingleInstance:
                return(Lifestyle.Singleton);

            case InstanceLifetimeType.Transient:
                return(Lifestyle.Transient);

            default:
                throw new NotSupportedException("LifetimeScope not found: " + lifetime);
            }
        }
 public IIocContainer Register <TInterface>(TInterface instance, InstanceLifetimeType lifetime)
     where TInterface : class
 {
     _container.Register(() => instance);
     return(this);
 }
 public IIocContainer Register(Type from, Type to, InstanceLifetimeType lifetime)
 {
     _container.Register(from, to, ConvertLifetimeType(lifetime));
     return(this);
 }