/// <summary>
 /// Set a single or group of options to the introJs object.
 /// </summary>
 /// <param name="action"></param>
 /// <returns></returns>
 public IntroJsInterop SetOption(Action <IntroJsOptions> action)
 {
     _options = CopyExistingOptions();
     action.Invoke(_options);
     _shouldOptionsBeApplied = true;
     return(this);
 }
 /// <summary>
 /// Set options with a json formatted object
 /// </summary>
 /// <param name="jsonOptions"></param>
 /// <returns></returns>
 public IntroJsInterop SetOptions(string jsonOptions)
 {
     _options = JsonSerializer.Deserialize <IntroJsOptions>(jsonOptions,
                                                            new JsonSerializerOptions()
     {
         PropertyNameCaseInsensitive = true,
         AllowTrailingCommas         = true
     });
     _shouldOptionsBeApplied = true;
     return(this);
 }
Пример #3
0
        /// <summary>
        /// Adds IntroJs classes to Service collection using default IntroJs Options
        /// </summary>
        /// <param name="services"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static IServiceCollection AddIntroJs(this IServiceCollection services, IConfiguration configuration = null)
        {
            IntroJsOptions options = null;

            if (configuration != null)
            {
                options = configuration.GetSection(nameof(IntroJsOptions)).Get <IntroJsOptions>();
            }

            services.AddTransient <IntroJsInterop>();
            services.AddTransient <IntroJsInteropEvents>();
            services.AddTransient <IntroJsOptions>(_ => options);

            return(services);
        }
        /// <summary>
        /// Instantiate a new instance IntroJsInterop
        /// </summary>
        /// <param name="jsRuntime"></param>
        /// <param name="events"></param>
        /// <param name="options"></param>
        public IntroJsInterop(IJSRuntime jsRuntime, IntroJsInteropEvents events, IntroJsOptions options)
        {
            _jsRuntime = jsRuntime;
            _events    = events;
            if (options is null)
            {
                _options = new IntroJsOptions();
            }
            else
            {
                _shouldOptionsBeApplied = true;
                _options = options;
            }

            _status = new IntroJsStatus();
        }
 /// <summary>
 /// Resets all IntroJs Options to default settings.  Removes configured settings for application.
 /// </summary>
 /// <returns></returns>
 public async ValueTask ResetOptions()
 {
     _options = new IntroJsOptions();
     await ApplyOptions();
 }