2021-04-22 16:50:39 +02:00
|
|
|
namespace Gtk
|
|
|
|
{
|
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Reflection;
|
2022-01-27 21:49:41 +01:00
|
|
|
using System.Runtime.CompilerServices;
|
2021-04-22 16:50:39 +02:00
|
|
|
|
|
|
|
public partial class CssProvider
|
|
|
|
{
|
2022-01-27 21:49:41 +01:00
|
|
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
2021-04-22 16:50:39 +02:00
|
|
|
public bool LoadFromResource(string resource) => LoadFromResource(Assembly.GetCallingAssembly(), resource);
|
|
|
|
|
2022-01-27 21:49:41 +01:00
|
|
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
2021-04-22 16:50:39 +02:00
|
|
|
public bool LoadFromResource(Assembly assembly, string resource)
|
|
|
|
{
|
|
|
|
if (assembly == null)
|
|
|
|
assembly = Assembly.GetCallingAssembly();
|
|
|
|
|
|
|
|
Stream stream = assembly.GetManifestResourceStream(resource);
|
|
|
|
if (stream == null)
|
|
|
|
throw new ArgumentException("'" + resource + "' is not a valid resource name of assembly '" + assembly + "'.", nameof(resource));
|
|
|
|
|
|
|
|
using (var reader = new StreamReader(stream))
|
|
|
|
{
|
|
|
|
string data = reader.ReadToEnd();
|
|
|
|
return LoadFromData(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|