/// <summary>
        /// Registers the type.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="serviceType">Type of the service.</param>
        /// <param name="implementationType">Type of the implementation.</param>
        /// <param name="asSingleton">if set to <c>true</c> [as singleton].</param>
        /// <returns></returns>
        public virtual IRegistrar RegisterType(string key, Type serviceType, Type implementationType, bool asSingleton)
        {
            Invariant.IsNotNull(serviceType, "serviceType");
            Invariant.IsNotNull(implementationType, "implementationType");

            ContainerBuilder builder = new ContainerBuilder();

            var registrar = builder.Register(implementationType).As(serviceType);

            registrar = asSingleton ? registrar.SingletonScoped() : registrar.FactoryScoped();

            if (!string.IsNullOrEmpty(key))
            {
                registrar.Named(key);
            }

            builder.Build(Container);

            return this;
        }
 protected override void Load(ContainerBuilder builder)
 {
     builder.Register<InMemoryDatabasae>().As<IDatabase>();
     builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
 }
        /// <summary>
        /// Registers the instance.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="serviceType">Type of the service.</param>
        /// <param name="instance">The instance.</param>
        /// <returns></returns>
        public virtual IRegistrar RegisterInstance(string key, Type serviceType, object instance)
        {
            Invariant.IsNotNull(serviceType, "serviceType");
            Invariant.IsNotNull(instance, "instance");

            ContainerBuilder builder = new ContainerBuilder();

            var registrar = builder.Register(instance).As(serviceType).ExternallyOwned();

            if (!string.IsNullOrEmpty(key))
            {
                registrar.Named(key);
            }

            builder.Build(Container);

            return this;
        }