|
1 | 1 | # Light.EmbeddedResources |
2 | 2 |
|
3 | 3 | [](https://github.com/feO2x/Light.EmbeddedResources/blob/master/LICENSE) |
4 | | -[](https://www.nuget.org/packages/Light.EmbeddedResources/) |
| 4 | +[](https://www.nuget.org/packages/Light.EmbeddedResources/) |
5 | 5 |
|
6 | 6 | ### Get hold of embedded streams the easy way... |
7 | 7 |
|
8 | 8 | Are you one of the C# devs that doesn't know by heart how to get hold of an embedded resource? Light.EmbeddedResources makes it easy for you via extension methods: |
9 | 9 |
|
10 | 10 | ```csharp |
| 11 | +// Either get it as a stream |
11 | 12 | using var stream = this.GetEmbeddedStream("EmailTemplate.html"); |
| 13 | + |
| 14 | +// ...or as a string |
| 15 | +string value = this.GetEmbeddedResource("EmailTemplate.html"); |
12 | 16 | ``` |
13 | 17 |
|
14 | 18 | If you work in a static method, you can use types: |
15 | 19 |
|
16 | 20 | ```csharp |
17 | 21 | using var stream = typeof(MyCurrentType).GetEmbeddedStream("EmailTemplate.html"); |
| 22 | +string value = typeof(MyCurrentType).GetEmbeddedResource("EmailTemplate.html"); |
18 | 23 | ``` |
19 | 24 |
|
20 | | -Just make sure that the instance / the type you call `GetEmbeddedStream` on is in the same assembly and namespace as the resource you want to retrieve. |
| 25 | +Just make sure that the instance / the type you call `GetEmbeddedStream` or `GetEmbeddedResource` on is in the same assembly and namespace as the resource you want to retrieve. |
21 | 26 |
|
22 | 27 | ### ...or copy them to files |
23 | 28 |
|
@@ -72,14 +77,14 @@ public class SomeService |
72 | 77 | Light.EmbeddedResources is compiled for |
73 | 78 |
|
74 | 79 | - .NET Standard 2.0 |
75 | | -- .NET Core 3.0 |
| 80 | +- .NET 5.0 |
76 | 81 |
|
77 | 82 | and runs on all platforms that support these (like full .NET Framework, Mono, Xamarin, Unity, UWP, etc.). |
78 | 83 |
|
79 | 84 | ## How to install |
80 | 85 |
|
81 | 86 | Light.EmbeddedResources is available as a [NuGet package](https://www.nuget.org/packages/Light.EmbeddedResources/): |
82 | 87 |
|
83 | | -- via csproj: `<PackageReference Include="Light.EmbeddedResources" Version="1.0.0" />` |
84 | | -- via .NET CLI: `dotnet add package Light.EmbeddedResources --version 1.0.0` |
85 | | -- via VS Package Manager: `Install-Package Light.EmbeddedResources -Version 1.0.0` |
| 88 | +- via csproj: `<PackageReference Include="Light.EmbeddedResources" Version="1.1.0" />` |
| 89 | +- via .NET CLI: `dotnet add package Light.EmbeddedResources --version 1.1.0` |
| 90 | +- via VS Package Manager: `Install-Package Light.EmbeddedResources -Version 1.1.0` |
0 commit comments