Skip to content

A utility for reading embedded resources from assemblies

Notifications You must be signed in to change notification settings

thomasgalliker/ResourceLoader

Repository files navigation

ResourceLoader

Version Downloads

ResourceLoader

ResourceLoader is a utility for reading embedded resources, such as XML files, images, etc. from assemblies.

Download and Install ResourceLoader

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.)

API Usage

Reading an embedded XML file

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"" ?>");

Using singleton implementation ResourceLoader.Current

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");

License

This project is Copyright © 2018 Thomas Galliker. Free for non-commercial use. For commercial use please contact the author.

About

A utility for reading embedded resources from assemblies

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published