Configuration File Xamarin Forms :
Hi guys , Today we are going to make configurable file for Xamarin forms app in Development and Production Scenario.
Where we really use it ?
It’s used in commercial app for code re-usability . if you are working with large scale application then you might have some Configuration Settings that needs to be changed back and forth. So i tried to solve that issue by creating two json file and all the changes will be triggered for release and debug mode.
So enjoy the flavor of code : ❤️
Step 1 :
At first and foremost , we are going to create AppSettings.cs file inside Helper/Configuration (Folder)
Inside App.Setting.cs :
Step 2 :
Then we are going to create a ConfigurationManager.cs inside same folders (Helper/Configuration)
Step 3 :
Now its time to create 2 Json File :
- AppSettings_Development_Default.json :
Step 4 :
Don’t forget to make this json file as Embedded resource.
We need to right click on the json file then click on properties then change built action to embedded resource .
Step 5 :
Create a new class ThemeManager.cs
How to call the stored key from the json ?
public class void ServiceCallMethod()
string GetAddress = ConfigurationManager.AppSetting.ServiceUrl;
That’ s all, this is how you create configurable file in Xamarin forms.
1,928 total views, 5 views today