Files
andy 9f22b522df v1.3.0 Restructure Saxonite workspace and upgrade to .NET 10 (#1)
Move Saxonite’s projects into a dedicated `Workspace` folder and align the solution with .NET 10 and the current Common workspace. Update encryption integration, test project structure and coverage, and repository guidance and upgrade notes.

- Relocate application and library projects while retaining Git rename history.
- Split tests into Admin, Online, and Shared projects; add representative behavioral and serialization tests.
- Update Common integration, application version, and repository documentation.

Application version: 1.3.0

Reviewed-on: #1
Co-authored-by: andy <andy@sarand.com>
2026-10-16 18:24:16 +01:00

128 lines
3.9 KiB
C#

using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Helpers;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
namespace Saxonite.Net.Standard.Base.Helpers
{
//=======================================================================
public static class SaxResourceHelper
{
//-------------------------------------------------------------------
// Definitions.
public enum TextResource
{
// Email stylesheets.
Email_Main_Css,
// Email partial content.
Email_Header_Html,
Email_Footer_Html,
// Email templates.
Email_Security_AccountActivated_Html,
Email_Security_RequestPassword_Html,
// Data - countries etc.
Data_CountriesWithRegions_Txt,
}
public enum ImageResource
{
Saxonite_logo_h75_png,
}
//-------------------------------------------------------------------
// Properties.
public static Assembly MyAssembly { get; } = typeof(SaxResourceHelper).GetTypeInfo().Assembly;
//-------------------------------------------------------------------
// Text resources.
/// <summary> Retrieve contents of text resource in this assembly by type.</summary>
public static String GetResourceText(TextResource textResource)
{
String partialPath = "";
String resourceFilename = "";
switch (textResource)
{
// Email stylesheet.
case TextResource.Email_Main_Css:
resourceFilename = "sax-email-main.css";
break;
// Email partial content.
case TextResource.Email_Header_Html:
resourceFilename = "sax-email-header.html";
break;
case TextResource.Email_Footer_Html:
resourceFilename = "sax-email-footer.html";
break;
// Email templates.
case TextResource.Email_Security_AccountActivated_Html:
resourceFilename = "sax-email-account-activated.html";
break;
case TextResource.Email_Security_RequestPassword_Html:
resourceFilename = "sax-email-request-password.html";
break;
// Data.
case TextResource.Data_CountriesWithRegions_Txt:
resourceFilename = "CountriesWithRegions.txt";
break;
}
return GetResourceText(resourceFilename, partialPath);
}
/// <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 "";
}
//-------------------------------------------------------------------
// Image resources.
public static byte[] GetResourceImage(ImageResource imageResource)
{
String partialPath = "";
String resourceFilename = "";
switch (imageResource)
{
case ImageResource.Saxonite_logo_h75_png:
resourceFilename = "saxonite-logo-h75.png";
break;
}
if (!StringUtil.IsEmpty(resourceFilename))
{
var assembly = typeof(SaxResourceHelper).GetTypeInfo().Assembly;
byte[] resourceData = SacsResourceHelper.GetManifestResourceAsBinary(assembly, partialPath, resourceFilename);
if (resourceData != null)
return resourceData;
}
return new byte[0];
}
//-------------------------------------------------------------------
// 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;
}
//-------------------------------------------------------------------
}
//=======================================================================
}