104 lines
3.0 KiB
C#
104 lines
3.0 KiB
C#
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_ContactUs_Html,
|
|
Email_Signup_Activate_Html,
|
|
Email_Signup_Welcome_Html,
|
|
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 = "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_ContactUs_Html:
|
|
resourceFilename = "sax-email-contact-us.html";
|
|
break;
|
|
case TextResource.Email_Signup_Activate_Html:
|
|
resourceFilename = "sax-email-signup-activate.html";
|
|
break;
|
|
case TextResource.Email_Signup_Welcome_Html:
|
|
resourceFilename = "sax-email-signup-welcome.html";
|
|
break;
|
|
case TextResource.Email_RequestPassword_Html:
|
|
resourceFilename = "sax-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];
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|