This project is read-only.
First download and install http://t4toolbox.codeplex.com/
Next, create a folder called "Templates" at the same level as your visual studio solution file.
Download the templates into this folder from SVN, here is the trunk:
https://dotnetcodegen.svn.codeplex.com/svn/trunk/Source/Templates/

To create a WCF service contract:
1) Create a new class library.
2) Add a new code generation script (.tt file) at the root of your project and put this code in it:

<#@ template language="C#" hostspecific="True" debug="True" #>
<#@ output extension="txt" #>
<#@ include file="T4Toolbox.tt" #>
<#@ include file="../Templates/ServiceContractGenerator.tt" #>
<#
(new ServiceContractGenerator(
"http://schema.bigbank.com/BigBankService/v1",
"BigBank.Contract",
"BigBankService",
new List<String> {
"GetAccounts",
"Transfer",
"GetAccountHistory",
"SubmitPayment"}
)).Run();
#>

3) Click save or "transform templates" button in Visual Studio. This will generate the source code for you.



To generate a service base and service implementation:
1) Generate a new WCF Service application.
2) Add a new code generation script at the root of your project and add some code like this:

<#@ template language="C#" hostspecific="True" debug="True" #>
<#@ output extension="txt" #>
<#@ include file="T4Toolbox.tt" #>
<#@ include file="../Templates/ServiceGenerator.tt" #>
<#
var operations = new List<String> {
"GetAccounts",
"Transfer",
"GetAccountHistory",
"SubmitPayment"};
var serviceName = "BigBankService";
(new ServiceBaseGenerator(
"BigBank.Contract",
"BigBank.Service",
serviceName,
operations
)).Run();
(new ServiceImpGenerator(
"BigBank.Contract",
"BigBank.Service",
"BigBank.Service",
serviceName,
serviceName + "Base",
operations
)).Run();
#>

3) Watch your service base, implementation, and unit test get generated!

Last edited Jan 26, 2011 at 10:31 PM by coolpablo, version 5

Comments

No comments yet.