Thanks to this thread.

A simple class does the job.

namespace Demo.SharePointTopNavDSL.CodeGenerator
{
[Guid("32BF3242-BB5A-4e5f-A457-3ADFA46A4549")]
ProvideCodeGenerator(typeof(PowerShellScriptGenerator),
"TopNavPowerShellScriptGenerator",
"A tool that generates PowerShell script based on the TopNav DSL", true)


public class PowerShellScriptGenerator : TemplatedCodeGenerator
{
protected override byte[] GenerateCode(string inputFileName, string inputFileContent)
{
FileInfo fi = new FileInfo(inputFileName);
StreamReader sr = new StreamReader(
GetType().Assembly.GetManifestResourceStream("Demo.SharePointTopNavDSL.Resources.PowerShell.template"));

inputFileContent = sr.ReadToEnd();
inputFileContent = inputFileContent.Replace("%MODELFILENAME%", fi.Name);
byte[] data = base.GenerateCode(inputFileName, inputFileContent);
return data;
}
}
}

codegenerator.png

Last edited Feb 26, 2008 at 6:01 PM by yysun, version 2

Comments

No comments yet.