Last change
on this file since 473 was 459, checked in by alloc, 16 months ago |
Updated to dashboard/marker files 0.8.0
Added initial OpenAPI support
|
File size:
996 bytes
|
Line | |
---|
1 | using System;
|
---|
2 | using System.IO;
|
---|
3 | using System.Reflection;
|
---|
4 |
|
---|
5 | namespace Webserver {
|
---|
6 | public static class ResourceHelpers {
|
---|
7 | public static Stream OpenManifestResource (Assembly _assembly, string _name, bool _ignoreCase = false) {
|
---|
8 | string[] resourceNames = _assembly.GetManifestResourceNames ();
|
---|
9 | foreach (string resourceName in resourceNames) {
|
---|
10 | if (!resourceName.EndsWith (_name, _ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)) {
|
---|
11 | continue;
|
---|
12 | }
|
---|
13 |
|
---|
14 | return _assembly.GetManifestResourceStream (resourceName);
|
---|
15 | }
|
---|
16 |
|
---|
17 | return null;
|
---|
18 | }
|
---|
19 |
|
---|
20 | public static string GetManifestResourceText (Assembly _assembly, string _name, bool _ignoreCase = false) {
|
---|
21 | using Stream manifestResourceStream = OpenManifestResource (_assembly, _name, _ignoreCase);
|
---|
22 | if (manifestResourceStream == null) {
|
---|
23 | return null;
|
---|
24 | }
|
---|
25 |
|
---|
26 | using TextReader reader = new StreamReader (manifestResourceStream);
|
---|
27 | return reader.ReadToEnd ();
|
---|
28 | }
|
---|
29 |
|
---|
30 | }
|
---|
31 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.