using System.IO;
using System.Reflection;
using CTA.Rules.Models;
namespace CTA.Rules.Config
{
public class TemplateHelper
{
private const string MultilineCommentOpen = "/*";
private const string MultilineCommentClose = "*/";
///
/// Gets the content of a template file
///
/// The file directory
/// The project namespace to be used when creating the template file
///
internal static string GetTemplateFileContent(string projectNamespace, ProjectType projectType, string fileName)
{
string file = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), GetProjectTypeTemplateDir(projectType), fileName);
string fileContent;
fileContent = File.ReadAllText(file);
return fileContent.Replace(MultilineCommentOpen, string.Empty).Replace(MultilineCommentClose, string.Empty).Replace(Constants.NameSpacePlaceHolder, projectNamespace);
}
///
/// Gets the directory containing the project template files, based on the project type
///
/// The project type
///
private static string GetProjectTypeTemplateDir(ProjectType projectType)
{
return Path.Combine(Constants.Templates, projectType.ToString().ToLower());
}
}
}