/// <summary> /// Load files in path and all sub directories. /// </summary> public void LoadFromDirectory(string path) { var log = new Logger("Loader"); if (!Directory.Exists(path)) { log.Error(string.Format(StringsScripting.Formatted_Directory_not_found, path)); return; } using (new LogTimed(log, string.Format(StringsScripting.Formatted_Log_Load_Start, path), string.Format(StringsScripting.Formatted_Log_Load_Finish, path))) { // load all input replace files. var files = Directory.GetFiles(path, "input replace.csv", SearchOption.AllDirectories); personControlLock.EnterWriteLock(); try { if (inputReplace == null) inputReplace = new List<Dictionary<string, string>>(); foreach (var file in files) { log.Info(string.Format(StringsScripting.Formatted_Log_Loading_file, file)); Logger fileLog; var rawLines = getFileLines(file, out fileLog); if (rawLines == null) continue; parseInputReplace(rawLines, fileLog); } } finally { personControlLock.ExitWriteLock(); } // load all .vtscript files. files = Directory.GetFiles(path, "*.vtscript", SearchOption.AllDirectories); foreach (string file in files) { log.Info(string.Format(StringsScripting.Formatted_Log_Loading_file, file)); Logger fileLog; // get all lines from the file. var rawLines = getFileLines(file, out fileLog); if (rawLines == null) continue; // get the base script key from the file name. string fileKey = KeyClean(Path.GetFileNameWithoutExtension(file)); // parse as a group parseScriptGroup(rawLines, file, fileKey, fileLog); } } }
public LogTimed(Logger log, string startMessage, string endMessage = null) { this.log = log; if (startMessage != null && startMessage.Length != 0) log.Info(startMessage); if (endMessage != null) EndMessage = endMessage; else EndMessage = startMessage; timmer = new Stopwatch(); timmer.Start(); }