/// <summary>
        /// Register dependencies using Autofac
        /// </summary>
        /// <param name="green">Startup Green configuration parameters</param>
        /// <param name="services">Collection of service descriptors</param>
        /// <param name="typeFinder">Type finder</param>
        protected virtual IServiceProvider RegisterDependencies(GreenConfig greenConfiguration, IServiceCollection services, ITypeFinder typeFinder)
        {
            var containerBuilder = new ContainerBuilder();

            //register engine
            containerBuilder.RegisterInstance(this).As <IEngine>().SingleInstance();

            //register type finder
            containerBuilder.RegisterInstance(typeFinder).As <ITypeFinder>().SingleInstance();

            //find dependency registrars provided by other assemblies
            var dependencyRegistrars = typeFinder.FindClassesOfType <IDependencyRegistrar>();

            //create and sort instances of dependency registrars
            var instances = dependencyRegistrars
                            .Select(dependencyRegistrar => (IDependencyRegistrar)Activator.CreateInstance(dependencyRegistrar))
                            .OrderBy(dependencyRegistrar => dependencyRegistrar.Order);

            //register all provided dependencies
            foreach (var dependencyRegistrar in instances)
            {
                dependencyRegistrar.Register(containerBuilder, typeFinder, greenConfiguration);
            }

            //populate Autofac container builder with the set of registered service descriptors
            containerBuilder.Populate(services);

            //create service provider
            _serviceProvider = new AutofacServiceProvider(containerBuilder.Build());
            return(_serviceProvider);
        }
        /// <summary>
        /// Register services and interfaces
        /// </summary>
        /// <param name="builder">Container builder</param>
        /// <param name="typeFinder">Type finder</param>
        /// <param name="config">Config</param>
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, GreenConfig config)
        {
            //web helper
            builder.RegisterType <WebHelper>().As <IWebHelper>().InstancePerLifetimeScope();

            //data layer
            builder.RegisterGeneric(typeof(EfRepository <>)).As(typeof(IRepository <>)).InstancePerLifetimeScope();

            //infrastracture
            builder.RegisterType <ScheduleTaskService>().As <IScheduleTaskService>().InstancePerLifetimeScope();
            builder.RegisterType <EncryptionService>().As <IEncryptionService>().InstancePerLifetimeScope();
            builder.RegisterType <SettingService>().As <ISettingService>().InstancePerLifetimeScope();
            builder.RegisterType <CookieAuthenticationService>().As <IAuthenticationService>();
            builder.RegisterType <ActionContextAccessor>().As <IActionContextAccessor>().InstancePerLifetimeScope();


            //app services
            builder.RegisterType <UserService>().As <IUserService>().InstancePerLifetimeScope();
            builder.RegisterType <CircleService>().As <ICircleService>().InstancePerLifetimeScope();
            builder.RegisterType <UserCircleService>().As <IUserCircleService>().InstancePerLifetimeScope();
            builder.RegisterType <InstallationService>().As <IInstallationService>().InstancePerLifetimeScope();


            //register all settings
            builder.RegisterSource(new SettingsSource());
        }