Catalyst is an SOA toolkit designed to facilitate fast and simple development of a powerful business object layer using the SubSonic framework.

It has 3 features to maximise performance and minimise database overhead whilst persisting data using seamless integration with SubSonic.

Features

  • Relational object framework
  • Collection caching
  • Custom serialization

More information to follow, as well as final source code and full release download in the coming days

Northwind Example

Territory Business Object

using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using Catalyst;
using Catalyst.Xml.Serialization;
using SubSonic;

namespace NorthwindBusinessObjects
{
	public class TerritoryCollection : DataObjectList<Territory, TerritoryCollection>
	{
		public override TableSchema.Table GetTableSchema()
		{
			return Northwind.DAL.Territory.Schema;
		}
	}

	[XmlSchemaProvider("ProvideSchema")]
	public class Territory : DataObject<Territory>, IXmlSerializable
	{
		public struct MappingNames
		{
			public const string Id = "Id";
			public const string Description = "Description";
			public const string Region = "Region";
		}

		public override MappingList GetMappings()
		{
			MappingList mappings = new MappingList();
			mappings.Add<int>(new DataMapping(MappingNames.Id, Northwind.DAL.Territory.TerritoryIDColumn));
			mappings.Add<string>(new DataMapping(MappingNames.Description, Northwind.DAL.Territory.TerritoryDescriptionColumn));
			mappings.Add<Region>(new DataMapping(MappingNames.Region, Northwind.DAL.Territory.RegionIDColumn));

			return mappings;
		}

		public override TableSchema.Table GetTableSchema()
		{
			return Northwind.DAL.Territory.Schema;
		}

		public int Id
		{
			get { return GetObjectValue<int>(MappingNames.Id); }
		}

		public string Description
		{
			get { return GetObjectValue<string>(MappingNames.Description); }
		}

		public Region Region
		{
			get { return GetObjectValue<Region>(MappingNames.Region); }
		}

		#region IXmlSerializable Members

		public static XmlQualifiedName ProvideSchema(XmlSchemaSet SchemaSet)
		{
			return XmlSerializer<Territory>.ProvideSchema(SchemaSet, Namespaces.Default);
		}

		public XmlSchema GetSchema()
		{
			return null;
		}

		public void ReadXml(XmlReader reader)
		{
			XmlSerializer<Territory>.Deserialize(reader, this);
		}

		public void WriteXml(XmlWriter writer)
		{
			XmlSerializer<Territory>.Serialize(writer, this);
		}

		#endregion
	}
}

Region Business Object

using Catalyst;
using SubSonic;

namespace NorthwindBusinessObjects
{
	public class RegionCollection : EnumeratorDataList<Region, RegionCollection>
	{
		public override TableSchema.Table GetTableSchema()
		{
			return Northwind.DAL.Region.Schema;
		}
	}

	public enum Region
	{
		Eastern = 1,
		Western = 2,
		Northern = 3,
		Southern = 4
	}
}

Web Service

using System.Web.Services;
using NorthwindBusinessObjects;

[WebService]
public class WebService : System.Web.Services.WebService
{
	[WebMethod]
	public TerritoryCollection GetTerritories()
	{
		TerritoryCollection territories = new TerritoryCollection().LoadAll();

		return territories;
	}
}

Web Method Result

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfTerritory>
  <Territory>
    <Id>1581</Id>
    <Description>Westboro</Description>
    <Region>Eastern</Region>
  </Territory>
  <Territory>
    <Id>1730</Id>
    <Description>Bedford</Description>
    <Region>Eastern</Region>
  </Territory>
  <Territory>
    <Id>1833</Id>
    <Description>Georgetow</Description>
    <Region>Eastern</Region>
  </Territory>
  <Territory>
    <Id>2116</Id>
    <Description>Boston</Description>
    <Region>Eastern</Region>
  </Territory>
  <Territory>
    <Id>2139</Id>
    <Description>Cambridge</Description>
    <Region>Eastern</Region>
  </Territory>
  <Territory>
    <Id>2184</Id>
    <Description>Braintree</Description>
    <Region>Eastern</Region>
  </Territory>
  <Territory>
    <Id>2903</Id>
    <Description>Providence</Description>
    <Region>Eastern</Region>
  </Territory>
  <Territory>
    <Id>3049</Id>
    <Description>Hollis</Description>
    <Region>Northern</Region>
  </Territory>
  <Territory>
    <Id>3801</Id>
    <Description>Portsmouth</Description>
    <Region>Northern</Region>
  </Territory>

...

  <Territory>
    <Id>98004</Id>
    <Description>Bellevue</Description>
    <Region>Western</Region>
  </Territory>
  <Territory>
    <Id>98052</Id>
    <Description>Redmond</Description>
    <Region>Western</Region>
  </Territory>
  <Territory>
    <Id>98104</Id>
    <Description>Seattle</Description>
    <Region>Western</Region>
  </Territory>
</ArrayOfTerritory>

Last edited May 5, 2009 at 4:26 PM by abrener, version 23