Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Json configuration file

$
0
0

Hey guys, I'm trying to add to my project a config.json file. I am following the steps indicated in the documentation article about this. https://xamarinhelp.com/configuration-files-xamarin-forms/

The very last step is to load the configuration files with this function:

public static async Task<IConfiguration> Build(IFileStorage fileStorage)
{ 
    var platformFile = await fileStorage.ReadAsString("platform.json");

    var platform = JsonConvert.DeserializeObject<Platform>(platformFile);

    var configurationFile = await fileStorage.ReadAsString("config.json");

    var configuration = JsonConvert.DeserializeObject<Definition.Configuration>(configurationFile);

    configuration.Platform = platform;

    return configuration;
}

But I can't make it work, as this line:

            var configuration = JsonConvert.DeserializeObject<Definition.Configuration>(configurationFile);

Is giving me an error on the word "Definition" saying that it cannot find the type or namespace "Definition" within my project. I have tried all I could (which is not much as I'm pretty new to this) and can't seem to make it work.

Anybody knows what I might be missing? As I followed each step of the article.


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>