/// <summary>
        /// Adds the required services for Rhetos dashboard controller.
        /// </summary>
        public static RhetosServiceCollectionBuilder AddDashboard(this RhetosServiceCollectionBuilder rhetosBuilder)
        {
            rhetosBuilder.Services
            .AddControllersWithViews()
            .AddApplicationPart(typeof(RhetosDashboardController).Assembly);

            rhetosBuilder.AddDashboardSnippet <ServerStatusSnippet>();
            rhetosBuilder.AddDashboardSnippet <InstalledPackagesSnippet>();

            return(rhetosBuilder);
        }
        /// <summary>
        /// Adds user impersonation components, including <see cref="IUserInfo"/> implementation for impersonated users and a dashboard snippet.
        /// </summary>
        public static RhetosServiceCollectionBuilder AddImpersonation(this RhetosServiceCollectionBuilder builder, Action <ImpersonationOptions> configureOptions = null)
        {
            builder.Services.AddHttpContextAccessor();

            builder.Services.AddOptions();
            if (configureOptions != null)
            {
                builder.Services.Configure(configureOptions);
            }

            builder.AddRestApiFilters();

            builder.ConfigureRhetosHost((serviceProvider, rhetosHostBuilder) =>
                                        rhetosHostBuilder.ConfigureContainer(containerBuilder =>
            {
                containerBuilder.Register(_ => serviceProvider.GetRequiredService <IHttpContextAccessor>()).SingleInstance().ExternallyOwned();
                containerBuilder.Register(_ => serviceProvider.GetRequiredService <IDataProtectionProvider>()).SingleInstance().ExternallyOwned();
                containerBuilder.Register(_ => serviceProvider.GetRequiredService <IOptions <ImpersonationOptions> >().Value).SingleInstance().ExternallyOwned();

                containerBuilder.RegisterType <RhetosAspNetCoreIdentityUser>().InstancePerMatchingLifetimeScope(UnitOfWorkScope.ScopeName);
                containerBuilder.Register <BaseAuthentication>(context => new BaseAuthentication(context.Resolve <RhetosAspNetCoreIdentityUser>())).InstancePerMatchingLifetimeScope(UnitOfWorkScope.ScopeName);
                containerBuilder.RegisterType <ImpersonationService>().InstancePerMatchingLifetimeScope(UnitOfWorkScope.ScopeName);
                containerBuilder.Register <IUserInfo>(context => context.Resolve <ImpersonationService>().GetUserInfo()).InstancePerMatchingLifetimeScope(UnitOfWorkScope.ScopeName);
            }));

            builder.Services.AddDataProtection();
            builder.Services.AddMvcCore()
            .AddApplicationPart(typeof(ImpersonationController).Assembly);

            builder.AddDashboardSnippet <ImpersonationDashboardSnippet>();

            return(builder);
        }
        public static RhetosServiceCollectionBuilder AddLightDMS(this RhetosServiceCollectionBuilder builder)
        {
            builder.Services.AddScoped <LightDmsService>();

            builder.Services
            .AddControllers()
            .ConfigureApplicationPartManager(p =>
            {
                p.FeatureProviders.Add(new LightDmsApiControllerFeatureProvider());
            });

            builder.AddDashboardSnippet <LightDmdDashboardSnippet>();

            return(builder);
        }