/// <summary> /// When overridden in a derived class, executes the task. /// </summary> /// <returns> /// true if the task successfully executed; otherwise, false. /// </returns> public override bool Execute() { RenderConfigConfig config = new RenderConfigConfig(); config.BreakOnNoMatch = breakOnNoMatch; config.CleanOutput = cleanOutput; config.ConfigFile = configFile; config.Configuration = configuration; config.DeleteOutputDirectory = deleteOutputDirectory; config.OutputDirectory = outputDirectory; config.InputDirectory = inputDirectory; config.SubDirectoryEachConfiguration = SubDirectoryEachConfiguration; config.PreserveSourceStructure = PreserveSourceStructure; IRenderConfigLogger log = new MSBuildLogger(Log); Boolean returnVal = true; try { RenderConfigEngine.RunAllConfigurations(config, log); } catch (Exception i) { log.LogError("Failed to render configuration : " + i.Message); return(false); } return(returnVal); }
public void Setup() { RenderConfigConfig config = GetConfigObject(); IRenderConfigLogger log = new ConsoleLogger(); RenderConfigEngine engine = new RenderConfigEngine(config, log); engine.Render(); }
public void Setup() { config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples",Path.DirectorySeparatorChar, "config.xml.xml"); config.Configuration = "xmlfilemodifier"; config.OutputDirectory = String.Concat("testing",Path.DirectorySeparatorChar, "xml"); config.BreakOnNoMatch = false; config.InputDirectory = "Examples"; }
public void Setup() { config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples", Path.DirectorySeparatorChar, "config.xml.xml"); config.Configuration = "xmlfilemodifier"; config.OutputDirectory = String.Concat("testing", Path.DirectorySeparatorChar, "xml"); config.BreakOnNoMatch = false; config.InputDirectory = "Examples"; }
public void Setup() { config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples", Path.DirectorySeparatorChar, "config.txt.xml"); config.Configuration = "textreplace"; config.OutputDirectory = String.Concat("testing", Path.DirectorySeparatorChar, "text"); config.InputDirectory = "examples"; config.BreakOnNoMatch = false; }
public void Setup() { config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples",Path.DirectorySeparatorChar,"config.other.xml"); config.Configuration = "config"; config.OutputDirectory = od.FullName; config.InputDirectory = "Examples"; config.BreakOnNoMatch = false; }
public void Setup() { config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples", Path.DirectorySeparatorChar, "config.other.xml"); config.Configuration = "config"; config.OutputDirectory = od.FullName; config.InputDirectory = "Examples"; config.BreakOnNoMatch = false; }
public void Setup() { config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples", Path.DirectorySeparatorChar, "config.txt.xml"); config.Configuration = "textreplace"; config.OutputDirectory = String.Concat("testing",Path.DirectorySeparatorChar,"text"); config.InputDirectory = "examples"; config.BreakOnNoMatch = false; }
private static RenderConfigConfig GetConfigObject() { RenderConfigConfig config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples", Path.DirectorySeparatorChar, "config.ini.xml"); config.Configuration = "inifilemodifier"; config.OutputDirectory = String.Concat("testing", Path.DirectorySeparatorChar, "ini"); config.InputDirectory = "Examples"; config.BreakOnNoMatch = false; return config; }
public void ExceptionOnUpdateMissingKey() { RenderConfigConfig config = GetConfigObject(); config.BreakOnNoMatch = true; config.Configuration = "inimissingkey"; IRenderConfigLogger log = new ConsoleLogger(); RenderConfigEngine engine = new RenderConfigEngine(config, log); Assert.Throws <System.Exception>(delegate { engine.Render(); }); }
private static RenderConfigConfig GetConfigObject() { RenderConfigConfig config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples", Path.DirectorySeparatorChar, "config.ini.xml"); config.Configuration = "inifilemodifier"; config.OutputDirectory = String.Concat("testing", Path.DirectorySeparatorChar, "ini"); config.InputDirectory = "Examples"; config.BreakOnNoMatch = false; return(config); }
public void ReplacementResultingInInvalidXmlThrowsException() { RenderConfigConfig config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples", Path.DirectorySeparatorChar, "config.xml.xml"); config.Configuration = "xmlreplacebad"; config.OutputDirectory = String.Concat("testing", Path.DirectorySeparatorChar, "xmlreplace"); config.InputDirectory = "examples"; config.BreakOnNoMatch = false; IRenderConfigLogger log = new ConsoleLogger(); RenderConfigEngine engine = new RenderConfigEngine(config, log); Assert.Throws <XmlException>(delegate { engine.Render(); }); }
public void ReplaceRepeatingSubString() { RenderConfigConfig config = GetConfigObject(); config.BreakOnNoMatch = true; config.Configuration = "inireplace"; IRenderConfigLogger log = new ConsoleLogger(); RenderConfigEngine engine = new RenderConfigEngine(config, log); engine.Render(); IConfigSource ini = new IniConfigSource(Path.Combine(od.FullName, "test.ini")); Assert.IsTrue(ini.Configs["Logging"].Contains("Replacement1")); Assert.IsTrue(ini.Configs["Logging"].Contains("Replacement2")); Assert.IsTrue(ini.Configs["Logging"].Contains("Replacement3")); }
public void SettingVariables() { RenderConfigConfig config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples", Path.DirectorySeparatorChar, "config.xml.xml"); config.Configuration = "variabletest1"; config.OutputDirectory = String.Concat("testing", Path.DirectorySeparatorChar, "variabletest1"); config.InputDirectory = "examples"; config.BreakOnNoMatch = false; IRenderConfigLogger log = new ConsoleLogger(); RenderConfigEngine engine = new RenderConfigEngine(config, log); engine.Render(); XmlDocument doc = new XmlDocument(); doc.Load(String.Concat("testing", Path.DirectorySeparatorChar, "variabletest1", Path.DirectorySeparatorChar, "test.xml")); Assert.AreEqual(doc.SelectSingleNode("/configuration/Random").InnerText, "variabletest1"); }
public void ReplaceMultipleSubString() { RenderConfigConfig config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples", Path.DirectorySeparatorChar, "config.xml.xml"); config.Configuration = "xmlreplace"; config.OutputDirectory = String.Concat("testing", Path.DirectorySeparatorChar, "xmlreplace"); config.InputDirectory = "examples"; config.BreakOnNoMatch = false; IRenderConfigLogger log = new ConsoleLogger(); RenderConfigEngine engine = new RenderConfigEngine(config, log); engine.Render(); XmlDocument doc = new XmlDocument(); doc.Load(String.Concat("testing", Path.DirectorySeparatorChar, "xmlreplace", Path.DirectorySeparatorChar, "xmlreplace.xml")); Assert.IsNotNull(doc.SelectSingleNode("/configuration/ReplacementRandom")); doc.Load(String.Concat("testing", Path.DirectorySeparatorChar, "xmlreplace", Path.DirectorySeparatorChar, "xmlreplace.ns.xml")); Assert.IsNotNull(doc.SelectSingleNode("/r:configuration/r:ReplacementRandom", GetManager(doc))); }
/// <summary> /// Main application entry point. /// </summary> /// <param name="args">The args.</param> static void Main(string[] args) { Boolean showHelp = false; Boolean showVersion = false; //Boolean verbose = false; RenderConfigConfig config = new RenderConfigConfig(); config.DeleteOutputDirectory = false; config.CleanOutput = false; config.BreakOnNoMatch = false; config.PreserveSourceStructure = false; config.SubDirectoryEachConfiguration = false; OptionSet options = null; try { options = new OptionSet() //.Add("v|verbose", "Not yet implemented", delegate(string v) { if (v != null) verbose = true; }) .Add("?|h|help", "Show this message and exit", delegate(string v) { if (v != null) { showHelp = true; } }) .Add("f=|file=", "File containing configuration", delegate(string v) { if (v != null) { config.ConfigFile = v; } else { throw new OptionException("Missing Configuration File", "f|file"); } }) .Add("c=|configuration=", "Target configuration", delegate(string v) { if (v != null) { config.Configuration = v; } else { throw new OptionException("Missing Configuration", "c|configuration"); } }) .Add("o=|output=", "Target output directory", delegate(string v) { if (v != null) { config.OutputDirectory = v; } else { throw new OptionException("Missing Output Directory", "o|output"); } }) .Add("i=|input=", "The input directory to use as the base for all relative source file paths", delegate(string v) { if (v != null) { config.InputDirectory = v; } }) .Add("d|deleteoutput", "Delete target output directory", delegate(string v) { if (v != null) { config.DeleteOutputDirectory = true; } }) .Add("l|clean", "Clean XML output files", delegate(string v) { if (v != null) { config.CleanOutput = true; } }) .Add("b|break", "Break on no match", delegate(string v) { if (v != null) { config.BreakOnNoMatch = true; } }) .Add("p|preserve", "Preserve source directory structure when outputting", delegate(string v) { if (v != null) { config.PreserveSourceStructure = true; } }) .Add("v|version", "Output the version", delegate(string v) { if (v != null) { showVersion = true; } }) .Add("s|subdirperconfig", "Output each configuration to a sub-directory under the output directory.", delegate(string v) { if (v != null) { config.SubDirectoryEachConfiguration = true; } }); options.Parse(args); } catch (OptionException e) { System.Console.WriteLine(); System.Console.WriteLine(e.Message); System.Console.WriteLine(); options.WriteOptionDescriptions(System.Console.Out); System.Console.ResetColor(); System.Environment.Exit(1); } if (showVersion) { ReportExeAndVersion(); System.Console.ResetColor(); System.Environment.Exit(1); } if (showHelp || args.Length == 0) { ReportExeAndVersion(); System.Console.WriteLine("Renders stuff"); options.WriteOptionDescriptions(System.Console.Out); System.Console.ResetColor(); System.Environment.Exit(1); } //HACK This is not right, shouldnt NDesk.Options be hanlding this shit???? if (config.OutputDirectory == null && !config.SubDirectoryEachConfiguration) { OutputArgumentError(options, "Please provide either an output directory or specify -s for a subdirectory per configuration"); } if (config.Configuration == null) { OutputArgumentError(options, "Please provide a target configuration"); } if (config.ConfigFile == null) { OutputArgumentError(options, "Please provide a config file to parse"); } try { IRenderConfigLogger log = new ConsoleLogger(); RenderConfigEngine.RunAllConfigurations(config, log); } catch (Exception i) { System.Console.WriteLine(); System.Console.WriteLine("Encountered error: " + i.Message); System.Console.WriteLine(); } System.Console.ResetColor(); }
public void ReplaceMultipleSubString() { RenderConfigConfig config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples",Path.DirectorySeparatorChar, "config.xml.xml"); config.Configuration = "xmlreplace"; config.OutputDirectory = String.Concat("testing",Path.DirectorySeparatorChar,"xmlreplace"); config.InputDirectory = "examples"; config.BreakOnNoMatch = false; IRenderConfigLogger log = new ConsoleLogger(); RenderConfigEngine engine = new RenderConfigEngine(config, log); engine.Render(); XmlDocument doc = new XmlDocument(); doc.Load(String.Concat("testing",Path.DirectorySeparatorChar,"xmlreplace",Path.DirectorySeparatorChar,"xmlreplace.xml")); Assert.IsNotNull(doc.SelectSingleNode("/configuration/ReplacementRandom")); doc.Load(String.Concat("testing", Path.DirectorySeparatorChar, "xmlreplace", Path.DirectorySeparatorChar, "xmlreplace.ns.xml")); Assert.IsNotNull(doc.SelectSingleNode("/r:configuration/r:ReplacementRandom", GetManager(doc))); }
public void ReplacementResultingInInvalidXmlThrowsException() { RenderConfigConfig config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples",Path.DirectorySeparatorChar, "config.xml.xml"); config.Configuration = "xmlreplacebad"; config.OutputDirectory = String.Concat("testing",Path.DirectorySeparatorChar, "xmlreplace"); config.InputDirectory = "examples"; config.BreakOnNoMatch = false; IRenderConfigLogger log = new ConsoleLogger(); RenderConfigEngine engine = new RenderConfigEngine(config, log); Assert.Throws<XmlException>(delegate {engine.Render();}); }
public void SettingVariables() { RenderConfigConfig config = new RenderConfigConfig(); config.ConfigFile = String.Concat("examples",Path.DirectorySeparatorChar, "config.xml.xml"); config.Configuration = "variabletest1"; config.OutputDirectory = String.Concat("testing",Path.DirectorySeparatorChar, "variabletest1"); config.InputDirectory = "examples"; config.BreakOnNoMatch = false; IRenderConfigLogger log = new ConsoleLogger(); RenderConfigEngine engine = new RenderConfigEngine(config, log); engine.Render(); XmlDocument doc = new XmlDocument(); doc.Load(String.Concat("testing", Path.DirectorySeparatorChar, "variabletest1", Path.DirectorySeparatorChar, "test.xml")); Assert.AreEqual(doc.SelectSingleNode("/configuration/Random").InnerText,"variabletest1"); }