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.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, } //------------------------------------------------------------------- // Text resources. public static String GetTextResource(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; } if (!StringUtil.IsEmpty(resourceFilename)) { var assembly = typeof(SaxResourceHelper).GetTypeInfo().Assembly; String resourceText = SacsResourceHelper.GetManifestResourceAsText(assembly, partialPath, resourceFilename); if (!StringUtil.IsEmpty(resourceText)) return resourceText; } return ""; } //------------------------------------------------------------------- // Image resources. public static byte[] GetImageResource(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]; } //------------------------------------------------------------------- } //======================================================================= }