using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Logging; namespace Tango.Protobuf { /// /// Represents an folder compilation result. /// /// public class CompilerFolderResult : ICompilerResult { private LogManager LogManager = LogManager.Default; /// /// Initializes a new instance of the class. /// /// The results. /// The language. /// The source path. /// The relative path. public CompilerFolderResult(IEnumerable results, CompilerLanguage language, String sourcePath, String relativePath) { Results = results; Language = language; SourcePath = sourcePath; RelativePath = relativePath; Name = Path.GetFileName(sourcePath); } /// /// Gets the compiler results. /// public IEnumerable Results { get; private set; } /// /// Gets the result language. /// public CompilerLanguage Language { get; private set; } /// /// Gets the result source path. /// public String SourcePath { get; private set; } /// /// Gets the result name. /// public String Name { get; private set; } /// /// Gets the result relative path. /// public String RelativePath { get; private set; } /// /// Saves the result to the specified folder. /// /// The folder. public void Save(string folder) { LogManager.Log("Saving " + folder + "..."); foreach (var fileResult in Results.OfType()) { fileResult.Save(folder); } foreach (var folderResult in Results.OfType()) { folderResult.Save(Path.Combine(folder, folderResult.RelativePath.TrimStart('\\','\\'))); } } /// /// Returns a that represents this instance. /// /// /// A that represents this instance. /// public override string ToString() { String output = Name + Environment.NewLine + ":"; foreach (var fileResult in Results.OfType()) { output += fileResult.ToString() + Environment.NewLine; } foreach (var folderResult in Results.OfType()) { output += folderResult.ToString() + Environment.NewLine; } return output; } } }