Skip to content

Commit

Permalink
T4テキスト・テンプレートへのパラメータ引き渡し成功 Issue #46
Browse files Browse the repository at this point in the history
------ auto generated message by Theolizer
TheolizerDriver  : 133dbf324ec5803600f60667b187ce28
TheolizerLibrary : f6256350d4e371e244fae66bede2e4e7
Library's Header : d41d8cd98f00b204e9800998ecf8427e
------ end of message
  • Loading branch information
yossi-tahara committed Jul 22, 2018
1 parent 0873a8c commit bf09f2d
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 12 deletions.
Expand Up @@ -7,23 +7,57 @@
// コードが再生成されると失われます。
// </auto-generated>
// ------------------------------------------------------------------------------
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System;

/// <summary>
/// Class to produce the template output
/// </summary>

#line 1 "L:\Data\DataOrig\3.Projects\3.Serializer\5.OpenBeta\Theolizer\source\cs_integration_test\theolizer\integrator\createSource.tt"
#line 1 "L:\Data\DataOrig\3.Projects\3.Serializer\5.OpenBeta\Theolizer\source\cs_integration_test\theolizer\integrator\CreateSource.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")]
public partial class createSource : createSourceBase
public partial class CreateSource : CreateSourceBase
{
#line hidden
/// <summary>
/// Create the template output
/// </summary>
public virtual string TransformText()
{
this.Write("Hello world\r\n");
this.Write("<html><body> \r\n<h2>Sales figures</h2> \r\n<table> \r\n");

#line 9 "L:\Data\DataOrig\3.Projects\3.Serializer\5.OpenBeta\Theolizer\source\cs_integration_test\theolizer\integrator\CreateSource.tt"
foreach (var item in m_data)
// m_data is declared in MyWebPageCode.cs
{

#line default
#line hidden
this.Write(" \r\n <tr><td> ");

#line 12 "L:\Data\DataOrig\3.Projects\3.Serializer\5.OpenBeta\Theolizer\source\cs_integration_test\theolizer\integrator\CreateSource.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(item.Name));

#line default
#line hidden
this.Write(" </td> \r\n <td> ");

#line 13 "L:\Data\DataOrig\3.Projects\3.Serializer\5.OpenBeta\Theolizer\source\cs_integration_test\theolizer\integrator\CreateSource.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(item.Value));

#line default
#line hidden
this.Write(" </td></tr> \r\n");

#line 14 "L:\Data\DataOrig\3.Projects\3.Serializer\5.OpenBeta\Theolizer\source\cs_integration_test\theolizer\integrator\CreateSource.tt"
} // end of foreach


#line default
#line hidden
this.Write(" \r\n</table>\r\n</body></html>\r\n");
return this.GenerationEnvironment.ToString();
}
}
Expand All @@ -35,7 +69,7 @@ public virtual string TransformText()
/// Base class for this transformation
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")]
public class createSourceBase
public class CreateSourceBase
{
#region Fields
private global::System.Text.StringBuilder generationEnvironmentField;
Expand Down
17 changes: 17 additions & 0 deletions source/cs_integration_test/theolizer/integrator/CreateSource.tt
@@ -0,0 +1,17 @@
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<html><body>
<h2>Sales figures</h2>
<table>
<# foreach (var item in m_data)
// m_data is declared in MyWebPageCode.cs
{ #>
<tr><td> <#= item.Name #> </td>
<td> <#= item.Value #> </td></tr>
<# } // end of foreach
#>
</table>
</body></html>
Expand Up @@ -49,11 +49,11 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemGroup>
<Compile Include="${CMAKE_CURRENT_SOURCE_DIR}/createSource.cs">
<Link>createSource.cs</Link>
<Compile Include="${CMAKE_CURRENT_SOURCE_DIR}/CreateSource.cs">
<Link>CreateSource.cs</Link>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>createSource.tt</DependentUpon>
<DependentUpon>CreateSource.tt</DependentUpon>
</Compile>
<Compile Include="${CMAKE_CURRENT_SOURCE_DIR}/meta_deserializer.cs">
<Link>meta_deserializer.cs</Link>
Expand All @@ -72,10 +72,10 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="${CMAKE_CURRENT_SOURCE_DIR}/createSource.tt">
<Link>createSource.tt</Link>
<Content Include="${CMAKE_CURRENT_SOURCE_DIR}/CreateSource.tt">
<Link>CreateSource.tt</Link>
<Generator>TextTemplatingFilePreprocessor</Generator>
<LastGenOutput>createSource.cs</LastGenOutput>
<LastGenOutput>CreateSource.cs</LastGenOutput>
</Content>
</ItemGroup>
<ItemGroup>
Expand Down

This file was deleted.

Expand Up @@ -15,6 +15,12 @@ static class Program
[STAThread]
static void Main(string[] args)
{
var data = new MyData[2];
data[0] = new MyData{ Name="abc", Value="def"};
data[1] = new MyData{ Name="ABC", Value="dEF"};
var template = new CreateSource(data);
Console.WriteLine(template.TransformText());

if (args.Length < 2)
{
Console.WriteLine("Need a parameter : <meta serialize file path> <output cs file>");
Expand All @@ -41,4 +47,14 @@ static void Main(string[] args)
}
}
}
public class MyData
{
public string Name;
public string Value;
}
}
partial class CreateSource
{
private theolizer.internal_space.MyData[] m_data;
public CreateSource(theolizer.internal_space.MyData[] data) { this.m_data = data; }
}

0 comments on commit bf09f2d

Please sign in to comment.