Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

Latest commit

 

History

History
58 lines (44 loc) · 2.23 KB

app_user_settings.md

File metadata and controls

58 lines (44 loc) · 2.23 KB

App/User Settings

Chromely provides storing and retrieval of application/user preferences settings. Developers can provide a custom settings class, but the class must implement IChromelyAppSettings. If none is provided it uses the default - DefaultAppSettings.

The default implementation of IChromelyAppSettings has the following features:

  • Property - AppName

    • Current application name
  • Property - DataPath

    • This is the full path of where the settings values are saved. If none is supplied it uses the OS SpecialFolder ApplicationFolder.
    • The filename is in the format: "{AppName}_appsettings.config";
  • Property - Settings

    • This is a dynamic property and allows the developer to save any "Key/Value" items.
    • Chromely exposes a static property to save and retrieve values
      • Samples:
        •      ChromelyAppUser.App.Properties.Settings.Item1 = "Market 01";
               ChromelyAppUser.App.Properties.Settings.Item2 = "Year 2020";
          
               var list = new List<string>();
               list.Add("item0001");
               list.Add("item0002");
               ChromelyAppUser.App.Properties.Settings.List1 = list;
  • Method - Read

    • Reads a previously saved settings on application launch.
  • Method - Save

    • Saves the current settings on application close.

To set a custom AppSettings:

AppBuilder
    .Create(args)
    .UseApp<CustomChromelyApp>()
    .Build()
    .Run();

public class CustomAppSettings : IChromelyAppSettings
{
}

public class CustomChromelyApp : ChromelyBasicApp
{
   public override void ConfigureServices(ServiceCollection services)
   {
      base.ConfigureServices(services);
      services.AddSingleton<IChromelyAppSettings, CustomAppSettings>();
   }
}