BSN.Common.PCLAppConfig

Cross platform Xamarin AppSettings reader


Keywords
xamarin, xamarin.forms, Standard, Config, App.Config, AppSettings, Configuration, ConfigurationManager, uwp, winrt, android, ios, monoandroid, monodroid, monotouch, xamariners
License
Apache-2.0
Install
Install-Package BSN.Common.PCLAppConfig -Version 1.0.7

Documentation

PCLAppConfig

Xamarin.Forms .Net Standard:

- PCL AppConfig : cross platfom xamarin forms app settings reader

Usage

  • Install PCLAppConfig package from nuget to your PCL and each target projects.

FOR FILE SYSTEM APP.CONFIG

  • Initialize ConfigurationManager.AppSettings on PCL project like below:
	ConfigurationManager.Initialise(PCLAppConfig.FileSystemStream.PortableStream.Current);
  • Add an app.config on your shared pcl project, and add your appSettings entries, as you would do with any app.config
  • Add this PCL app.config file as a linked file on all your platform projects. For android, make sure to set the build action to 'AndroidAsset', for UWP set the build action to 'Content'

FOR EMBEDDED APP.CONFIG

  • Initialize ConfigurationManager.AppSettings on your pcl project like below:
	Assembly assembly = typeof(App).GetTypeInfo().Assembly;
	ConfigurationManager.Initialise(assembly.GetManifestResourceStream("DemoApp.App.config"));	
  • Add an App.config on your shared pcl project and ensure that Build Action:EmbeddedResource, and add your appSettings entries, as you would do with any App.config
<configuration>
	<appSettings>
        <add key="config.text" value="hello from app.settings!" />
    </appSettings>
</configuration>
  • Access your setting:
	ConfigurationManager.AppSettings["config.text"];

Author

  • Ben Ishiyama-levy (Xamariners)

Contributors

  • Seyyed Soroosh Hosseinalipour

Roadmap

  • Add encryption

Comments and suggestions are welcomed!