diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Protobuf/CompilerFileResult.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Protobuf/CompilerFileResult.cs | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Protobuf/CompilerFileResult.cs b/Software/Visual_Studio/Tango.Protobuf/CompilerFileResult.cs new file mode 100644 index 000000000..244ee3857 --- /dev/null +++ b/Software/Visual_Studio/Tango.Protobuf/CompilerFileResult.cs @@ -0,0 +1,81 @@ +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 +{ + /// <summary> + /// Represents an <see cref="IProtoCompiler"/> file compilation result. + /// </summary> + /// <seealso cref="Tango.Protobuf.ICompilerResult" /> + public class CompilerFileResult : ICompilerResult + { + /// <summary> + /// Gets the result language. + /// </summary> + public CompilerLanguage Language { get; private set; } + + /// <summary> + /// Gets the result name. + /// </summary> + public String Name { get; private set; } + + /// <summary> + /// Gets the result source path. + /// </summary> + public String SourcePath { get; private set; } + + /// <summary> + /// Gets the file content. + /// </summary> + public String Content { get; private set; } + + /// <summary> + /// Gets or sets the relative file path. + /// </summary> + internal String RelativePath { get; private set; } + + /// <summary> + /// Initializes a new instance of the <see cref="CompilerFileResult"/> class. + /// </summary> + /// <param name="language">The language.</param> + /// <param name="sourcePath">The source path.</param> + /// <param name="fileName">Name of the file.</param> + /// <param name="content">File contents.</param> + public CompilerFileResult(CompilerLanguage language, String sourcePath, String fileName, String relativePath, String content) + { + Language = language; + SourcePath = sourcePath; + Name = fileName; + RelativePath = relativePath; + Content = content; + } + + /// <summary> + /// Saves the result to the specified folder. + /// </summary> + /// <param name="folder">The folder.</param> + public void Save(String folder) + { + LogManager.Log("Saving " + Path.Combine(folder, Name) + "..."); + + Directory.CreateDirectory(folder); + File.WriteAllText(Path.Combine(folder, Name), Content); + } + + /// <summary> + /// Returns a <see cref="System.String" /> that represents this instance. + /// </summary> + /// <returns> + /// A <see cref="System.String" /> that represents this instance. + /// </returns> + public override string ToString() + { + return Name; + } + } +} |
