This library is available on NuGet: https://www.nuget.org/packages/ResourceLoader/ Use the following command to install ResourceLoader using NuGet package manager console:
PM> Install-Package ResourceLoader
You can use this library in any .Net project which is compatible to PCL (e.g. Xamarin Android, iOS, Windows Phone, Windows Store, Universal Apps, etc.)
The following unit test shows how an XML file (XMLFile1.xml) can be read from the current assembly.
// Arrange
IResourceLoader resourceLoader = new ResourceLoader();
// Act
string embeddedResourceString = resourceLoader.GetEmbeddedResourceString(this.GetType().Assembly, "XMLFile1.xml");
// Assert
embeddedResourceString.Should().NotBeNull();
embeddedResourceString.Should().Be(@"<?xml version=""1.0"" encoding=""utf-8"" ?>");
If you do not use an IoC framework, you can call ResourceLoader.Current directly to get a singleton instance of IResourceLoader.
string embeddedResourceString = ResourceLoader.Current.GetEmbeddedResourceString(this.GetType().Assembly, "XMLFile1.xml");
This project is Copyright © 2018 Thomas Galliker. Free for non-commercial use. For commercial use please contact the author.