public static string BuildPath(string directory, string file, bool overwrite) { file = ValueReplacer.InjectVariables(new MemoryGlobalVariables(), file); var fi = new FileInfo($"{directory}\\{file}"); var fileBase = fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length); if (!fi.Directory.Exists) { fi.Directory.Create(); } if (fi.Exists) { if (!ScriptEngine.ConfigurationSettings.Settings.FileLoggerSettings.Overwrite) { fi = new FileInfo($"{fi.DirectoryName}\\{fileBase}_{DateTime.Now.ToString("MMddyyyyHHmmss")}{fi.Extension}"); } else { fi.Delete(); } } return(fi.FullName); }
/// <summary> /// Replace placeholders with variables /// </summary> /// <param name="variables">Name/Value dictionary</param> public void InjectVariables(IGlobalVariables variables) { Dictionary <IPath, string> tempValues = new Dictionary <IPath, string>(); foreach (var value in Values) { Logger.Log($"Before injection: {value.Key} => {value.Value}", MessageTypes.ScriptAction | MessageTypes.Internal); tempValues.Add(value.Key, ValueReplacer.InjectVariables(variables, value.Value)); Logger.Log($"After injection: {value.Key} => {value.Value}", MessageTypes.ScriptAction | MessageTypes.Internal); } Values.Clear(); Values = tempValues; }
public PreCompiler(Boolean remote) { replacer = new ValueReplacer(); isRemote = remote; }
/// <summary> /// Replace placeholders with variables /// </summary> /// <param name="variables">Name/Value dictionary</param> public void InjectVariables(IGlobalVariables variables) { Logger.Log($"Before injection: Text => {Text}", MessageTypes.ScriptAction | MessageTypes.Internal); Text = ValueReplacer.InjectVariables(variables, Text); Logger.Log($"After injection: Text => {Text}", MessageTypes.ScriptAction | MessageTypes.Internal); }
private sealed Boolean isRemote; // skip certain processing for remote tests public PreCompiler() { replacer = new ValueReplacer(); isRemote = false; }