Browse Source

Add WCF REST project and file templates.

pull/20/merge
Eusebiu Marcu 14 years ago
parent
commit
9481311b5d
  1. 55
      data/templates/file/CSharp/CSharp.WcfRestService.xft
  2. 50
      data/templates/file/VB/VB.WcfRestService.xft
  3. 104
      data/templates/project/CSharp/CSharp.WcfRestServiceProject.xpt
  4. 42
      data/templates/project/CSharp/CSharp.WcfServiceProject.xpt
  5. 99
      data/templates/project/VB/VB.WcfRestServiceProject.xpt
  6. 43
      data/templates/project/VB/VB.WcfServiceProject.xpt
  7. 12
      src/Setup/Files.wxs
  8. 5
      src/Setup/Setup.wxs

55
data/templates/file/CSharp/CSharp.WcfRestService.xft

@ -0,0 +1,55 @@
<?xml version="1.0"?>
<Template
author="Eusebiu Marcu"
created="13/09/2011"
lastModified="13/09/2011"
version="1.0">
<Config
name="WCF REST Service"
icon="C#.File.NewClass"
category="C#"
subcategory="WCF"
defaultname="Service${Number}.svc"
language="C#"/>
<Description>WCF REST Service</Description>
<Files>
<File name="${FullName}">
<![CDATA[
<%@ServiceHost language="C#" Debug="true" Service="${StandardNamespace}.${ClassName}"%>
]]>
</File>
<File name="${FullName}.cs" language="C#" DependentUpon="${FullName}">
<![CDATA[${StandardHeader.C#}
using System;
using System.ServiceModel;
using System.ServiceModel.Web;
namespace ${StandardNamespace}
{
[ServiceContract]
public interface I${ClassName}
{
[OperationContract]
[WebGet(UriTemplate = "operation/{name}")]
string MyOperation(string name);
}
/// <summary>
/// Description of ${ClassName}.
/// </summary>
public class ${ClassName} : I${ClassName}
{
public string MyOperation(string name)
{
// implement the operation
return string.Format("Operation name: {0}", name);
}
}
}
]]>
</File>
</Files>
</Template>

50
data/templates/file/VB/VB.WcfRestService.xft

@ -0,0 +1,50 @@
<?xml version="1.0"?>
<Template
author="Eusebiu Marcu"
created="13/09/2011"
lastModified="01/09/2011"
version="1.0">
<Config
name="WCF REST Service"
icon="VBNet.File.NewClass"
category="VB"
subcategory="WCF"
defaultname="Service${Number}.svc"
language="VBNET"/>
<Description>WCF REST Service</Description>
<Files>
<File name="${FullName}">
<![CDATA[
<%@ServiceHost language="VB" Debug="true" Service="${StandardNamespace}.${ClassName}"%>
]]>
</File>
<File name="${FullName}.vb" language="VBNET" DependentUpon="${FullName}">
<![CDATA[${StandardHeader.VBNET}
Imports System
Imports System.ServiceModel
Imports System.ServiceModel.Web
<ServiceContract> _
Public Interface I${ClassName}
<OperationContract> _
<WebGet(UriTemplate := "operation/{name}")> _
Function MyOperation(name As String) As String
End Interface
''' <summary>
''' Description of ${ClassName}.
''' </summary>
Public Class ${ClassName}
Implements I${ClassName}
Function MyOperation(name As String) As String Implements I${ClassName}.MyOperation
' implement the operation
Return String.Format("Operation name: {0}", name)
End Sub
End Class
]]>
</File>
</Files>
</Template>

104
data/templates/project/CSharp/CSharp.WcfRestServiceProject.xpt

@ -0,0 +1,104 @@
<?xml version="1.0"?>
<Template
author="Eusebiu Marcu"
created="13/09/2011"
lastModified="13/09/2011"
version="1.0">
<!-- Template Header -->
<TemplateConfiguration>
<Name>WCF REST Service</Name>
<Category>C#</Category>
<Subcategory>WCF</Subcategory>
<Icon>C#.Project.Form</Icon>
<Description>WCF REST Service</Description>
<SupportedTargetFrameworks>v3.5</SupportedTargetFrameworks>
</TemplateConfiguration>
<!-- Actions -->
<Actions>
<Open filename="Service.svc.cs"/>
</Actions>
<Project language="C#">
<ProjectItems>
<Reference Include="System" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" />
</ProjectItems>
<PropertyGroup escapeValue="False">
<OutputType>Library</OutputType>
<ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<AppDesignerFolder>Properties</AppDesignerFolder>
</PropertyGroup>
<PropertyGroup configuration="Debug">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<PropertyGroup configuration="Release">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<Files>
<File name="Properties\AssemblyInfo.cs" src="DefaultAssemblyInfo.cs" />
<File name="Service.svc">
<![CDATA[
<%@ServiceHost language="C#" Debug="true" Service="${StandardNamespace}.Service"%>
]]>
</File>
<File name="Service.svc.cs" DependentUpon="Service.svc">
<![CDATA[${StandardHeader.C#}
using System;
using System.ServiceModel;
using System.ServiceModel.Web;
namespace ${StandardNamespace}
{
[ServiceContract]
public interface IService
{
[OperationContract]
[WebGet(UriTemplate = "operation/{name}")]
string MyOperation(string name);
}
public class Service : IService
{
public string MyOperation(string name)
{
// implement the operation
return string.Format("Operation name: {0}", name);
}
}
}
]]>
</File>
<File name="web.config">
<![CDATA[<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="${StandardNamespace}.Service">
<endpoint address=""
binding="webHttpBinding"
contract="${StandardNamespace}.IService"
behaviorConfiguration="webHttp" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
]]>
</File>
</Files>
</Project>
</Template>

42
data/templates/project/CSharp/CSharp.WcfServiceProject.xpt

@ -17,7 +17,7 @@
<!-- Actions --> <!-- Actions -->
<Actions> <Actions>
<Open filename="ServiceCalculator.svc.cs"/> <Open filename="Service.svc.cs"/>
</Actions> </Actions>
<Project language="C#"> <Project language="C#">
@ -42,12 +42,12 @@
<Files> <Files>
<File name="Properties\AssemblyInfo.cs" src="DefaultAssemblyInfo.cs" /> <File name="Properties\AssemblyInfo.cs" src="DefaultAssemblyInfo.cs" />
<File name="ServiceCalculator.svc"> <File name="Service.svc">
<![CDATA[ <![CDATA[
<%@ServiceHost language="C#" Debug="true" Service="${StandardNamespace}.ServiceCalculator"%> <%@ServiceHost language="C#" Debug="true" Service="${StandardNamespace}.Service"%>
]]> ]]>
</File> </File>
<File name="ServiceCalculator.svc.cs" DependentUpon="ServiceCalculator.svc"> <File name="Service.svc.cs" DependentUpon="Service.svc">
<![CDATA[${StandardHeader.C#} <![CDATA[${StandardHeader.C#}
using System; using System;
using System.ServiceModel; using System.ServiceModel;
@ -55,35 +55,17 @@ using System.ServiceModel;
namespace ${StandardNamespace} namespace ${StandardNamespace}
{ {
[ServiceContract] [ServiceContract]
public interface ICalculator public interface IService
{ {
[OperationContract] [OperationContract]
double Add(double n1, double n2); void MyOperation();
[OperationContract]
double Subtract(double n1, double n2);
[OperationContract]
double Multiply(double n1, double n2);
[OperationContract]
double Divide(double n1, double n2);
} }
public class ServiceCalculator : ICalculator public class Service : IService
{ {
public double Add(double n1, double n2) public void MyOperation()
{
return n1 + n2;
}
public double Subtract(double n1, double n2)
{
return n1 - n2;
}
public double Multiply(double n1, double n2)
{
return n1 * n2;
}
public double Divide(double n1, double n2)
{ {
return n1 / n2; // implement the operation
} }
} }
} }
@ -94,12 +76,10 @@ namespace ${StandardNamespace}
<configuration> <configuration>
<system.serviceModel> <system.serviceModel>
<services> <services>
<!-- This section is optional with the default configuration model introduced in .NET Framework 4 --> <service name="${StandardNamespace}.Service">
<service name="${StandardNamespace}.ServiceCalculator">
<!-- This endpoint is exposed at the base address provided by host: http://localhost/${ProjectName}/ServiceCalculator.svc -->
<endpoint address="" <endpoint address=""
binding="wsHttpBinding" binding="wsHttpBinding"
contract="${StandardNamespace}.ICalculator" /> contract="${StandardNamespace}.IService" />
</service> </service>
</services> </services>
</system.serviceModel> </system.serviceModel>

99
data/templates/project/VB/VB.WcfRestServiceProject.xpt

@ -0,0 +1,99 @@
<?xml version="1.0"?>
<Template
author="Eusebiu Marcu"
created="13/09/2011"
lastModified="13/09/2011"
version="1.0">
<!-- Template Header -->
<TemplateConfiguration>
<Name>WCF REST Service</Name>
<Category>VB</Category>
<Subcategory>WCF</Subcategory>
<Icon>VBNet.Project.Form</Icon>
<Description>WCF REST Service</Description>
<SupportedTargetFrameworks>v3.5</SupportedTargetFrameworks>
</TemplateConfiguration>
<!-- Actions -->
<Actions>
<Open filename="Service.svc.vb"/>
</Actions>
<Project language="VBNet">
<ProjectItems>
<Reference Include="System" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" />
</ProjectItems>
<PropertyGroup escapeValue="False">
<OutputType>Library</OutputType>
<ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<AppDesignerFolder>Properties</AppDesignerFolder>
</PropertyGroup>
<PropertyGroup configuration="Debug">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<PropertyGroup configuration="Release">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<Files>
<File name="Properties\AssemblyInfo.vb" src="DefaultAssemblyInfo.vb" />
<File name="Service.svc">
<![CDATA[
<%@ServiceHost language="VB" Debug="true" Service="${StandardNamespace}.Service"%>
]]>
</File>
<File name="Service.svc.vb" DependentUpon="Service.svc">
<![CDATA[${StandardHeader.VBNET}
Imports System
Imports System.ServiceModel
Imports System.ServiceModel.Web
<ServiceContract> _
Public Interface IService
<OperationContract> _
<WebGet(UriTemplate := "operation/{name}")> _
Function MyOperation(name As String) As String
End Interface
Public Class Service
Implements IService
Function MyOperation(name As String) As String Implements IService.MyOperation
' implement the operation
Return String.Format("Operation name: {0}", name)
End Function
End Class
]]>
</File>
<File name="web.config">
<![CDATA[<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="${StandardNamespace}.Service">
<endpoint address=""
binding="webHttpBinding"
contract="${StandardNamespace}.IService"
behaviorConfiguration="webHttp" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
]]>
</File>
</Files>
</Project>
</Template>

43
data/templates/project/VB/VB.WcfServiceProject.xpt

@ -17,7 +17,7 @@
<!-- Actions --> <!-- Actions -->
<Actions> <Actions>
<Open filename="ServiceCalculator.svc.vb"/> <Open filename="Service.svc.vb"/>
</Actions> </Actions>
<Project language="VBNet"> <Project language="VBNet">
@ -42,42 +42,27 @@
<Files> <Files>
<File name="Properties\AssemblyInfo.vb" src="DefaultAssemblyInfo.vb" /> <File name="Properties\AssemblyInfo.vb" src="DefaultAssemblyInfo.vb" />
<File name="ServiceCalculator.svc"> <File name="Service.svc">
<![CDATA[ <![CDATA[
<%@ServiceHost language="VB" Debug="true" Service="${StandardNamespace}.ServiceCalculator"%> <%@ServiceHost language="VB" Debug="true" Service="${StandardNamespace}.Service"%>
]]> ]]>
</File> </File>
<File name="ServiceCalculator.svc.vb" DependentUpon="ServiceCalculator.svc"> <File name="Service.svc.vb" DependentUpon="Service.svc">
<![CDATA[${StandardHeader.VBNET} <![CDATA[${StandardHeader.VBNET}
Imports System Imports System
Imports System.ServiceModel Imports System.ServiceModel
<ServiceContract> _ <ServiceContract> _
Public Interface ICalculator Public Interface IService
<OperationContract> _ <OperationContract> _
Function Add(n1 As Double, n2 As Double) As Double Sub MyOperation()
<OperationContract> _
Function Subtract(n1 As Double, n2 As Double) As Double
<OperationContract> _
Function Multiply(n1 As Double, n2 As Double) As Double
<OperationContract> _
Function Divide(n1 As Double, n2 As Double) As Double
End Interface End Interface
Public Class ServiceCalculator Public Class Service
Implements ICalculator Implements IService
Public Function Add(n1 As Double, n2 As Double) As Double Implements ICalculator.Add Public Sub MyOperation() Implements IService.MyOperation
Return n1 + n2 ' implement the operation
End Function End Sub
Public Function Subtract(n1 As Double, n2 As Double) As Double Implements ICalculator.Subtract
Return n1 - n2
End Function
Public Function Multiply(n1 As Double, n2 As Double) As Double Implements ICalculator.Multiply
Return n1 * n2
End Function
Public Function Divide(n1 As Double, n2 As Double) As Double Implements ICalculator.Divide
Return n1 / n2
End Function
End Class End Class
]]> ]]>
</File> </File>
@ -86,12 +71,10 @@ End Class
<configuration> <configuration>
<system.serviceModel> <system.serviceModel>
<services> <services>
<!-- This section is optional with the default configuration model introduced in .NET Framework 4 --> <service name="${StandardNamespace}.Service">
<service name="${StandardNamespace}.ServiceCalculator">
<!-- This endpoint is exposed at the base address provided by host: http://localhost/${ProjectName}/ServiceCalculator.svc -->
<endpoint address="" <endpoint address=""
binding="wsHttpBinding" binding="wsHttpBinding"
contract="${StandardNamespace}.ICalculator" /> contract="${StandardNamespace}.IService" />
</service> </service>
</services> </services>
</system.serviceModel> </system.serviceModel>

12
src/Setup/Files.wxs

@ -730,6 +730,9 @@
<Component Id="CSharpWcfServiceFileTemplate" Guid="FBCEE100-BE0D-11E0-A9F2-C7D14824019B" DiskId="1"> <Component Id="CSharpWcfServiceFileTemplate" Guid="FBCEE100-BE0D-11E0-A9F2-C7D14824019B" DiskId="1">
<File Id="CSharp.WcfService.xft" Name="CSharp.WcfService.xft" Source="..\..\data\templates\file\CSharp\CSharp.WcfService.xft" KeyPath="yes" /> <File Id="CSharp.WcfService.xft" Name="CSharp.WcfService.xft" Source="..\..\data\templates\file\CSharp\CSharp.WcfService.xft" KeyPath="yes" />
</Component> </Component>
<Component Id="CSharpWcfRestServiceFileTemplate" Guid="00AE5E3C-DD9C-11E0-A234-EEB74724019B" DiskId="1">
<File Id="CSharp.WcfRestService.xft" Name="CSharp.WcfRestService.xft" Source="..\..\data\templates\file\CSharp\CSharp.WcfRestService.xft" KeyPath="yes" />
</Component>
</Directory> </Directory>
<Directory Id="MiscFileTemplatesFolder" Name="Misc"> <Directory Id="MiscFileTemplatesFolder" Name="Misc">
<Component Guid="F47EE9EB-321F-4D98-A373-BFE2C2D801D0" Id="EmptyHTMLFileTemplate" DiskId="1"> <Component Guid="F47EE9EB-321F-4D98-A373-BFE2C2D801D0" Id="EmptyHTMLFileTemplate" DiskId="1">
@ -804,6 +807,9 @@
<Component Id="VBWcfServiceFileTemplate" Guid="A1EABE3E-BE0D-11E0-A4E6-5BD14824019B" DiskId="1"> <Component Id="VBWcfServiceFileTemplate" Guid="A1EABE3E-BE0D-11E0-A4E6-5BD14824019B" DiskId="1">
<File Id="VB.WcfService.xft" Name="VB.WcfService.xft" Source="..\..\data\templates\file\VB\VB.WcfService.xft" KeyPath="yes" /> <File Id="VB.WcfService.xft" Name="VB.WcfService.xft" Source="..\..\data\templates\file\VB\VB.WcfService.xft" KeyPath="yes" />
</Component> </Component>
<Component Id="VBWcfRestServiceFileTemplate" Guid="28AB44B8-DD9C-11E0-AEE3-30B84724019B" DiskId="1">
<File Id="VB.WcfRestService.xft" Name="VB.WcfRestService.xft" Source="..\..\data\templates\file\VB\VB.WcfRestService.xft" KeyPath="yes" />
</Component>
</Directory> </Directory>
</Directory> </Directory>
<Directory Id="ProjectTemplatesFolder" Name="project"> <Directory Id="ProjectTemplatesFolder" Name="project">
@ -848,6 +854,9 @@
<Component Id="CSharpWcfServiceProjectTemplate" Guid="D793DD78-BE0C-11E0-AC34-34D04824019B" DiskId="1"> <Component Id="CSharpWcfServiceProjectTemplate" Guid="D793DD78-BE0C-11E0-AC34-34D04824019B" DiskId="1">
<File Id="CSharp.WcfServiceProject.xpt" Name="CSharp.WcfServiceProject.xpt" Source="..\..\data\templates\project\CSharp\CSharp.WcfServiceProject.xpt" KeyPath="yes" /> <File Id="CSharp.WcfServiceProject.xpt" Name="CSharp.WcfServiceProject.xpt" Source="..\..\data\templates\project\CSharp\CSharp.WcfServiceProject.xpt" KeyPath="yes" />
</Component> </Component>
<Component Id="CSharpWcfRestServiceProjectTemplate" Guid="8FEE65EC-DD9C-11E0-8968-81B84724019B" DiskId="1">
<File Id="CSharp.WcfRestServiceProject.xpt" Name="CSharp.WcfRestServiceProject.xpt" Source="..\..\data\templates\project\CSharp\CSharp.WcfRestServiceProject.xpt" KeyPath="yes" />
</Component>
</Directory> </Directory>
<Directory Id="MiscProjectTemplatesFolder" Name="Misc"> <Directory Id="MiscProjectTemplatesFolder" Name="Misc">
<Component Guid="F9A7F832-6EC8-4B15-A037-146BD028C9D5" Id="MiscProjectTemplates" DiskId="1"> <Component Guid="F9A7F832-6EC8-4B15-A037-146BD028C9D5" Id="MiscProjectTemplates" DiskId="1">
@ -889,6 +898,9 @@
<Component Id="VBWcfServiceProjectTemplate" Guid="FF1C11DA-BE0C-11E0-A35E-6FD04824019B" DiskId="1"> <Component Id="VBWcfServiceProjectTemplate" Guid="FF1C11DA-BE0C-11E0-A35E-6FD04824019B" DiskId="1">
<File Id="VB.WcfServiceProject.xpt" Name="VB.WcfServiceProject.xpt" Source="..\..\data\templates\project\VB\VB.WcfServiceProject.xpt" KeyPath="yes" /> <File Id="VB.WcfServiceProject.xpt" Name="VB.WcfServiceProject.xpt" Source="..\..\data\templates\project\VB\VB.WcfServiceProject.xpt" KeyPath="yes" />
</Component> </Component>
<Component Id="VBWcfRestServiceProjectTemplate" Guid="A45203E0-DD9C-11E0-974A-93B84724019B" DiskId="1">
<File Id="VB.WcfRestServiceProject.xpt" Name="VB.WcfRestServiceProject.xpt" Source="..\..\data\templates\project\VB\VB.WcfRestServiceProject.xpt" KeyPath="yes" />
</Component>
</Directory> </Directory>
<Component Guid="73EAC135-57B6-46C0-9F24-70A347B9AAC8" Id="ExampleProjectTemplate" DiskId="1"> <Component Guid="73EAC135-57B6-46C0-9F24-70A347B9AAC8" Id="ExampleProjectTemplate" DiskId="1">
<File Source="..\..\data\templates\project\ComplexExample.xpt.test" Id="ComplexExample.xpt.test" Name="ComplexExample.xpt.test" /> <File Source="..\..\data\templates\project\ComplexExample.xpt.test" Id="ComplexExample.xpt.test" Name="ComplexExample.xpt.test" />

5
src/Setup/Setup.wxs

@ -318,6 +318,11 @@
<ComponentRef Id="VBWcfServiceProjectTemplate"/> <ComponentRef Id="VBWcfServiceProjectTemplate"/>
<ComponentRef Id="VBWcfServiceFileTemplate"/> <ComponentRef Id="VBWcfServiceFileTemplate"/>
<ComponentRef Id="CSharpWcfRestServiceProjectTemplate"/>
<ComponentRef Id="CSharpWcfRestServiceFileTemplate"/>
<ComponentRef Id="VBWcfRestServiceProjectTemplate"/>
<ComponentRef Id="VBWcfRestServiceFileTemplate"/>
<ComponentRef Id="EmptyHTMLFileTemplate"/> <ComponentRef Id="EmptyHTMLFileTemplate"/>
<ComponentRef Id="EmptyMsBuildFileTemplate"/> <ComponentRef Id="EmptyMsBuildFileTemplate"/>
<ComponentRef Id="EmptyResourceFileTemplate"/> <ComponentRef Id="EmptyResourceFileTemplate"/>

Loading…
Cancel
Save