blob: feef53b9aa336813690229e8e6f33eba887cd752 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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; internal 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;
}
}
}
|