EntitySpaces has teamed up with Justin Greenwood (shown left) of MyGeneration Software to create a brand new code generation engine for EntitySpaces 2009. Because of Justin's code generation expertise we contacted Justin and asked him to create a very simple, lightweight code generation engine whose only job is to execute templates. (There is no user interface support by design.) The code generation engine makes the EntitySpaces MetdataEngine available as an intrinsic object available to all templates through the "esMeta" property. We already have a working version of the code generation engine and thought we would share our progress with you.
We have created a test form that invokes the code generation engine for testing. Here is the button click event that kicks the whole thing off.
using EntitySpaces.MetadataEngine;using EntitySpaces.CodeGenerator; namespace Test{ public partial class Form1 : Form { private void btnGenerate_Click(object sender, EventArgs e) { EntitySpaces.MetadataEngine.Root esMeta = new EntitySpaces.MetadataEngine.Root(); esMeta.Connect("SQL", this.txtConnectionString.Text); // I'm Connection to Northwind esMeta.LanguageMappingFileName = @"esLanguages.xml"; esMeta.UserMetaDataFileName = @"esUserData.xml"; esMeta.esPlugInSettingsFileName = @"esSettings.xml"; esMeta.Language = "C#"; Template template = new Template(); template.Execute(esMeta, "Master.est"); } }}
using EntitySpaces.MetadataEngine;using EntitySpaces.CodeGenerator;
namespace Test{ public partial class Form1 : Form { private void btnGenerate_Click(object sender, EventArgs e) { EntitySpaces.MetadataEngine.Root esMeta = new EntitySpaces.MetadataEngine.Root(); esMeta.Connect("SQL", this.txtConnectionString.Text); // I'm Connection to Northwind esMeta.LanguageMappingFileName = @"esLanguages.xml"; esMeta.UserMetaDataFileName = @"esUserData.xml"; esMeta.esPlugInSettingsFileName = @"esSettings.xml"; esMeta.Language = "C#";
Template template = new Template(); template.Execute(esMeta, "Master.est"); } }}
Here is what the "Master.est" template looks like. In the code above the connection string was set to the Microsoft SQL Northwind database and we have hard-coded the "Employees" table in the master template shown below.
Notice in the code above we execute a sub template named "Sub.est" and append it's output to our currently running template. We also show how you can have separate "pure code blocks" via the <script> tag. Below is the Sub.est template which is passed the "esMeta" object from the Master template and then runs through all of the columns in the Orders table.
The output from the execution of the master template looks like this:
EmployeeID LastName FirstName Title TitleOfCourtesy BirthDate HireDate Address City Region PostalCode Country HomePhone Extension Photo Notes ReportsTo PhotoPath <START|-|Wow, very cool|-|END> --> Sub.est OrderID CustomerID EmployeeID OrderDate RequiredDate ShippedDate ShipVia Freight ShipName ShipAddress ShipCity ShipRegion ShipPostalCode ShipCountry
EmployeeID LastName FirstName Title TitleOfCourtesy BirthDate HireDate Address City Region PostalCode Country HomePhone Extension Photo Notes ReportsTo PhotoPath
<START|-|Wow, very cool|-|END>
--> Sub.est
OrderID CustomerID EmployeeID OrderDate RequiredDate ShippedDate ShipVia Freight ShipName ShipAddress ShipCity ShipRegion ShipPostalCode ShipCountry
At this point we have everything in place to provide a Beta version of EntitySpaces 2009 in a very short time frame. By having this all in house our code generation will be extremely easy for EntitySpaces 2009 and will not rely on third party tools. This also allows for our new code snippet model where a template is nothing more than a collection of code snippets which can be tweaked and replaced by our customers.
Take a look at this mock master template.
All the master does is execute a set of sub templates that make up, for example, the single esEntity object. Now imagine a very cool UI that allows you to manage, edit, and customize these snippets and replace or tweak our properties, INotify support, or just add other methods and properties to your entities. And the best thing is you will not need to be a code generation expert, not by a long shot. We are very excited about EntitySpaces 2009. This is only a part of what is coming in 2009. Domain modeling and much more are on tap.
For more on EntitySpaces 2009 take a look at our roadmap HERE.
From mobile devices to large scale enterprise solutions in need of serious transaction support, EntitySpaces can meet your needs. Whether you’re writing an ASP.NET application with medium trust requirements, a Mono application, or a Windows.Forms application, the EntitySpaces architecture is there for you. EntitySpaces is provider independent, which means that you can run the same binary code against any of the supported databases. EntitySpaces is available in both C# and VB.NET. EntitySpaces uses no reflection, no XML files, and sports a tiny foot print of less than 200k. Pound for pound, EntitySpaces is one tough, dependable .NET architecture.
The EntitySpaces Team--
EntitySpaces LLCPersistence Layer and Business Objects for Microsoft .NEThttp://www.entityspaces.net
Page rendered at Saturday, March 13, 2010 9:56:19 PM (Eastern Standard Time, UTC-05:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.