Using XAG to Create a WCF Service

Here's a good example of what you could use XAG for. Using XAG, the below XML document compiles to a WCF Service Project. It contains an interface, a class implementing the interface, a few data contracts, and all appropriate references.

As you can see, you can include a literal configuration in the XML structure. This will be included as an app.config in your project.

What is XAG? XAG is a new FREE .NET 2.0/3.0 architecture and development tool allowing the creation of entire VS2005 projects in a single XML structure. You can access XAG at http://www.jampadtechnology.com/xag/

<Assembly xmlns:x="http://www.jampadtechnology.com/xag/2006/11/">
  <References>
    <Reference Name="System.Runtime.Serialization " />
    <Reference Name="System.ServiceModel" />
  </References>
  <Folder Header="Data Contracts">
    <Person x:Key="Person" Type="Class" AutoGenerateConstructorsByProperties="True" AccessModifier="Public" Namespace="AcmeCorp.Sales ">
      <Attributes>
        <Attribute Type="DataContract" Namespace="System.Runtime.Serialization" />
      </Attributes>
      <Properties>
        <FirstName Type="String" />
        <LastName Type="String" />
        <Address1 Type="String" />
        <Address2 Type="String" />
        <City Type="String" />
        <State Type="String" />
        <PostalCode Type="String" />
      </Properties>
    </Person>
    <CreditCard x:Key="CreditCard" Type="Class" AccessModifier="Public" Namespace="AcmeCorp.Sales">
      <Attributes>
        <Attribute Type="DataContract" Namespace="System.Runtime.Serialization" />
      </Attributes>
      <Properties>
        <Number Type="String" />
        <Cvv2 Type="String" />
        <Name Type="String" />
        <ExpDate Type="String" />
      </Properties>
    </CreditCard>
    <Item x:Key="Item" Type="Class" AccessModifier="Public" Namespace="AcmeCorp.Sales">
      <Attributes>
        <Attribute Type="DataContract" Namespace="System.Runtime.Serialization" />
      </Attributes>
      <Properties>
        <ItemCode Type="String" />
        <Name Type="String" />
        <Price Type="Decimal" />
      </Properties>
    </Item>
    <Cart x:Key="Cart" Type="Class" AccessModifier="Public" Namespace="AcmeCorp.Sales ">
      <Attributes>
        <Attribute Type="DataContract" Namespace="System.Runtime.Serialization" />
      </Attributes>
      <Aliases>
        <Alias x:Key="LineItemsCollection" Name="LineItemsCollection" Type="System.Collections.ObjectModel.Collection [{Type Item}]" />
      </Aliases>
      <Properties>
        <LineItems Type="{Type LineItemsCollection}" />
      </Properties>
    </Cart>
    <Sale x:Key="Sale" Type="Class" AccessModifier="Public" Namespace="AcmeCorp.Sales">
      <Attributes>
        <Attribute Type="DataContract" Namespace="System.Runtime.Serialization " />
      </Attributes>
      <Properties>
        <Person AccessModifier="Public" Type="{Type Person}" InstantiateObject="True" />
        <CreditCard AccessModifier="Public" Type="{Type CreditCard}" />
        <Cart AccessModifier="Public" Type="{Type Cart}" />
      </Properties>
    </Sale>
  </Folder>
  <Folder Header="Services">
    <IProcessorService x:Key="IProcessorService" Type="Interface" AccessModifier="Public" Namespace="AcmeCorp.ServiceContracts">
      <Attributes>
        <Attribute Type="ServiceContract" Namespace="System.ServiceModel" Reference="System.ServiceModel" />
      </Attributes>
      <Methods>
        <ProcessSale ReturnType="Void">
          <Attributes>
            <Attribute Type="OperationContract" Namespace="System.ServiceModel" />
          </Attributes>
          <Parameters>
            <Parameter Name="sale" Type="{Type Sale}" />
          </Parameters>
        </ProcessSale>
      </Methods>
    </IProcessorService>
    <ProcessorService Type="Class" AccessModifier="Public" Namespace="AcmeCorp.Service">
      <Implements>
        <Interface Name="{Type IProcessorService}" Namespace="System" />
      </Implements>
    </ProcessorService>
  </Folder>
  <Configuration>
    <!--
// Sample Console Application

using System;
using System.ServiceModel;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args) {
            using (ServiceHost service = new ServiceHost(typeof(AcmeCorp.Service.ProcessorService))) {
                service.Open( );
                Console.WriteLine("Listening...");
                Console.ReadLine( );
            }
        }
    }
}
-->
    <system.serviceModel>
      <services>
        <service name="AcmeCorp.Service.ProcessorService" behaviorConfiguration="Service1Behavior">
          <host>
            <baseAddresses>
              <add baseAddress="http://localhost:3827/"/>
              <add baseAddress="net.pipe://localhost/"/>
            </baseAddresses>
          </host>
          <endpoint address="" contract="AcmeCorp.ServiceContracts.IProcessorService" binding="netNamedPipeBinding"/>
          <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/>
        </service>
      </services>
      <behaviors>
        <serviceBehaviors>
          <behavior name="Service1Behavior">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="true"/>
          </behavior>
        </serviceBehaviors>
      </behaviors>
    </system.serviceModel>
  </Configuration>
</Assembly>