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 Sarand.BusinessMgr.Net.Standard.Base.Helpers { //======================================================================= public static class SbmResourceHelper { //------------------------------------------------------------------- // Definitions. public enum TextResource { // Email stylesheets. Email_Main_Css, // Email partial content. Email_Header_Html, Email_Footer_Html, // Email templates. Email_RequestPassword_Html, // Data - CSV files etc. } public enum ImageResource { BusinessMgr_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 = "sbm-email-main.css"; break; // Email partial content. case TextResource.Email_Header_Html: resourceFilename = "sbm-email-header.html"; break; case TextResource.Email_Footer_Html: resourceFilename = "sbm-email-footer.html"; break; // Email templates. case TextResource.Email_RequestPassword_Html: resourceFilename = "sbm-email-request-password.html"; break; // Data. } if (!StringUtil.IsEmpty(resourceFilename)) { var assembly = typeof(SbmResourceHelper).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.BusinessMgr_logo_h75_png: resourceFilename = "BusinessMgr-logo-h75.png"; break; } if (!StringUtil.IsEmpty(resourceFilename)) { var assembly = typeof(SbmResourceHelper).GetTypeInfo().Assembly; byte[] resourceData = SacsResourceHelper.GetManifestResourceAsBinary(assembly, partialPath, resourceFilename); if (resourceData != null) return resourceData; } return new byte[0]; } //------------------------------------------------------------------- } //======================================================================= }