57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using Sarand.Net.Standard.Base.Helpers;
|
|
using Sarand.Net.Standard.Base.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Saxonite.Net.Core.Web.Base.Helpers
|
|
{
|
|
//=======================================================================
|
|
public static class SaxResourceHelper_Web
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Definitions.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
public static Assembly MyAssembly { get; } = typeof(SaxResourceHelper_Web).GetTypeInfo().Assembly;
|
|
|
|
//-------------------------------------------------------------------
|
|
// Text resources.
|
|
|
|
/// <summary> Retrieve contents of text resource in this assembly by name.</summary>
|
|
public static String GetResourceText(String resourceFilename, String partialPath = "")
|
|
{
|
|
if (!StringUtil.IsBlank(resourceFilename))
|
|
{
|
|
String resourceText = SacsResourceHelper.GetManifestResourceAsText(MyAssembly, partialPath, resourceFilename);
|
|
if (!StringUtil.IsBlank(resourceText))
|
|
return resourceText;
|
|
}
|
|
return "";
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Resource stream.
|
|
|
|
/// <summary>
|
|
/// Retrieve stream to resource in this assembly.
|
|
/// </summary>
|
|
public static Stream GetResourceStream(String resourceFilename, String partialPath = "")
|
|
{
|
|
if (!StringUtil.IsBlank(resourceFilename))
|
|
{
|
|
return SacsResourceHelper.GetManifestResourceStream(MyAssembly, partialPath, resourceFilename);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|