public ThemeHandler(IServiceProvider serviceProvider, ThemeOptions options) { _options = options ?? throw new ArgumentNullException(nameof(options)); _store = options.ThemeStoreFactory?.Invoke(serviceProvider); _activeTheme = options.InitialTheme ?? ThemeTypes.Light; LoadFromStoreAsync(); }
public static void AddTheming(this IServiceCollection services, Action <ThemeOptions>?configure) { var options = new ThemeOptions(); // Add default formatters options.CssValueFormatters.Add(typeof(KeyAlias), new CssKeyAliasFormatter()); options.CssValueFormatters.Add(typeof(Color), new CssColorFormatter()); configure?.Invoke(options); services.AddSingleton <IStyleScopeHandler>( sp => new StyleScopeHandler(sp.GetRequiredService <IHeadManager>(), options.CssValueFormatters)); services.AddSingleton <IThemeHandler>( sp => new ThemeHandler(sp, options)); }