public override string Execute(StringTemplateItem template) { string file = PathUtility.ParseSpecialFoldersNames(this.File, ParseSpecialFolderOption.WildCardToRealPath); string line = string.Empty; string[] values = new string[0]; StringBuilder sb = new StringBuilder(); if (Utils.IsFileOrDirectory(file) == Utils.FileOrDirectory.File) { using (StreamReader reader = new StreamReader(file)) { while (!reader.EndOfStream) // Do not use EndOfStream { line = reader.ReadLine(); template.IsLastCommand = (reader.EndOfStream && this.IsLastCommand); values = Utils.SplitByPosition(line, Positions); sb.Append(template.Format(line, this.Data, values)); } reader.Close(); } } return(sb.ToString()); }
public override string Execute(StringTemplateItem template) { StringBuilder sb = new StringBuilder(); for (int ii = 0; ii < Count; ii++) { template.IsLastCommand = ((ii == Count - 1) && this.IsLastCommand); sb.Append(template.Format(ii.ToString(), this.Data, new string[0])); } return(sb.ToString()); }
public override string Execute(StringTemplateItem template) { string directory = PathUtility.ParseSpecialFoldersNames(this.Directory, ParseSpecialFolderOption.WildCardToRealPath); StringBuilder sb = new StringBuilder(); if (Utils.IsFileOrDirectory(directory) == Utils.FileOrDirectory.Directory) { List <string> files = Utils.GetFiles(directory, Filter, Recursive); for (int ii = 0; ii < files.Count; ii++) { string file = files[ii]; FileInfo fi = new FileInfo(file); string[] inf = new string[] { fi.FullName, fi.Directory.FullName, fi.DirectoryName, fi.Name, fi.Extension, fi.Length.ToString(), fi.CreationTime.ToString("yyyyMMdd hh:mm:ss"), fi.LastAccessTime.ToString("yyyyMMdd hh:mm:ss"), fi.LastWriteTime.ToString("yyyyMMdd hh:mm:ss") }; string line = string.Join(";", inf); template.IsLastCommand = ((ii == files.Count - 1) && this.IsLastCommand); sb.Append(template.Format(line, this.Data, file)); } } return(sb.ToString()); }
public override string Execute(StringTemplateItem template) { string directory = PathUtility.ParseSpecialFoldersNames(this.Directory, ParseSpecialFolderOption.WildCardToRealPath); StringBuilder sb = new StringBuilder(); if (Utils.IsFileOrDirectory(directory) == Utils.FileOrDirectory.Directory) { List <string> directories = Utils.GetDirectories(directory, Recursive); for (int ii = 0; ii < directories.Count; ii++) { string dir = directories[ii]; DirectoryInfo dirInfo = new DirectoryInfo(dir); string[] inf = new string[] { dirInfo.FullName, dirInfo.Name, dirInfo.CreationTime.ToString("yyyyMMdd hh:mm:ss"), dirInfo.LastAccessTime.ToString("yyyyMMdd hh:mm:ss"), dirInfo.LastWriteTime.ToString("yyyyMMdd hh:mm:ss") }; string line = string.Join(";", inf); template.IsLastCommand = ((ii == directories.Count - 1) && this.IsLastCommand); sb.Append(template.Format(line, this.Data, dir)); } } return(sb.ToString()); }
public virtual string Execute(StringTemplateItem template) { return(template.Format(Line, Data, LineValues)); }