Replace tt template with generated code
This commit is contained in:
parent
076ab987b1
commit
1c6f185989
|
|
@ -53,47 +53,48 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string outputNamespace = Host.ResolveParameterValue("directiveId", "namespaceDirectiveProcessor", "namespaceHint") ?? projectName;
|
GenerationEnvironment.AppendFormat(
|
||||||
#>
|
@"// <auto-generated />
|
||||||
// <auto-generated />
|
|
||||||
|
|
||||||
namespace <#= outputNamespace #>
|
namespace {0}
|
||||||
{
|
{{
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Resources;
|
using System.Resources;
|
||||||
|
|
||||||
internal static class <#= fileName #>
|
internal static class {1}
|
||||||
{
|
{{
|
||||||
private static readonly ResourceManager _resourceManager
|
private static readonly ResourceManager _resourceManager
|
||||||
= new ResourceManager("<#= projectName + "." + fileName #>", typeof(<#= fileName #>).GetTypeInfo().Assembly);
|
= new ResourceManager(""{0}.{1}"", typeof({1}).GetTypeInfo().Assembly);
|
||||||
<#
|
", projectName, fileName);
|
||||||
foreach (var resourceString in resourceStrings)
|
foreach (var resourceString in resourceStrings)
|
||||||
{
|
{
|
||||||
#>
|
GenerationEnvironment.AppendLine();
|
||||||
|
GenerationEnvironment.AppendFormat(@" /// <summary>").AppendLine();
|
||||||
/// <summary>
|
foreach (var line in resourceString.Value.Split(new[] { Environment.NewLine }, StringSplitOptions.None))
|
||||||
<# foreach (var line in resourceString.Value.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) { #>
|
{
|
||||||
/// <#= line.Replace("<", "<").Replace(">", ">") #>
|
GenerationEnvironment.AppendFormat(" /// {0}", line.Replace("<", "<").Replace(">", ">"))
|
||||||
<# } #>
|
.AppendLine();
|
||||||
/// </summary>
|
}
|
||||||
internal static string <#= resourceString.Name #><#= resourceString.ArgsCount > 0 ? resourceString.ParamsArray : string.Empty #>
|
GenerationEnvironment.AppendFormat(
|
||||||
{
|
@" /// </summary>
|
||||||
<#
|
internal static string {0}{1}
|
||||||
if (resourceString.ArgsCount == 0)
|
{{
|
||||||
{
|
", resourceString.Name, resourceString.ArgsCount > 0 ? resourceString.ParamsArray : string.Empty);
|
||||||
#>get { return GetString("<#= resourceString.Name #>"); }
|
if (resourceString.ArgsCount == 0)
|
||||||
<#
|
{
|
||||||
}
|
GenerationEnvironment.AppendFormat(
|
||||||
else
|
@" get {{ return GetString(""{0}""); }}", resourceString.Name);
|
||||||
{
|
}
|
||||||
#>return string.Format(CultureInfo.CurrentCulture, GetString("<#= resourceString.Name #>"), <#= resourceString.ArgsArray #>);
|
else
|
||||||
<#
|
{
|
||||||
}#>
|
GenerationEnvironment.AppendFormat(
|
||||||
}
|
@" return string.Format(CultureInfo.CurrentCulture, GetString(""{0}""), {1});", resourceString.Name, resourceString.ArgsArray);
|
||||||
<#
|
}
|
||||||
}#>
|
GenerationEnvironment.AppendLine().Append(
|
||||||
|
@" }").AppendLine();
|
||||||
|
}
|
||||||
|
GenerationEnvironment.Append(@"
|
||||||
private static string GetString(string name)
|
private static string GetString(string name)
|
||||||
{
|
{
|
||||||
string value = _resourceManager.GetString(name);
|
string value = _resourceManager.GetString(name);
|
||||||
|
|
@ -102,6 +103,8 @@ namespace <#= outputNamespace #>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
");
|
||||||
|
#>
|
||||||
<#
|
<#
|
||||||
string outputPath = Path.Combine(ttDirectory, fileName + ".Designer.cs");
|
string outputPath = Path.Combine(ttDirectory, fileName + ".Designer.cs");
|
||||||
bool fileExists = File.Exists(outputPath);
|
bool fileExists = File.Exists(outputPath);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue