- nhibernate.zip
- NHibernate
- Everything-1.0.sln
- Everything-1.0.suo
- Newin.scp
- NHibernate
- Northwind
- Northwind.Core
- bin
- Debug
- Northwind.Core.dll
- NorthwindDomain.dll
- ProjectBase.Utils.dll
- DataInterfaces
- Domain
- Hbm
- mssccprj.scc
- nhibernate-mapping.xsd
- nhibernate-mapping.xsx
- Northwind.Core.csproj
- Northwind.Core.csproj.vspscc
- Properties
- vssver2.scc
- Northwind.Data
- Northwind.Web
- ProjectBase.Utils
- WebTemplates
- bin
- Debug
- SmartCode.Model.DLL
- SmartCode.Template.dll
- WebTemplates.dll
- WebTemplates.pdb
- Default.cs
- Edit
- Helper.cs
- List
- mssccprj.scc
- obj
- Properties
- vssver2.scc
- WebTemplates.csproj
- WebTemplates.csproj.user
- WebTemplates.csproj.vspscc
|
using System;
using System.Collections.Generic;
using System.Text;
using SmartCode.Template;
using SmartCode.Model;
namespace NHibernateTemplates
{
public class DataInterfaces: TemplateBase
{
public DataInterfaces()
{
CreateOutputFile = true;
Description = "Generates a C# class for the Data Interface";
Name = "DataInterfaces";
OutputFolder = "NHibernate/DataInterfaces";
}
public override string OutputFileName()
{
return String.Format("I{0}Dao.cs", Helper.MakeSingle(Entity.Code));
}
public override void ProduceCode()
{
IList<ColumnSchema> primaryKeyColumns = Table.PrimaryKeyColumns();
if (primaryKeyColumns.Count > 0)
{
WriteLine(@"using System;");
WriteLine(@"using System.Collections.Generic;");
WriteLine(@"using {0}.Core.Domain;", Helper.PascalCase(Domain.Code));
W();
WriteLine(@"namespace {0}.Core.DataInterfaces", Helper.PascalCase(Domain.Code) );
WriteLine(@"{");
WriteLine(@" /// <summary>");
WriteLine(@" /// Since this extends the <see cref=""IDao{TypeOfListItem, IdT}"" /> behavior, it's a good idea to ");
WriteLine(@" /// place it in its own file for manageability. In this way, it can grow further without");
WriteLine(@" /// cluttering up <see cref=""IDaoFactory"" />.");
WriteLine(@" /// </summary>");
if (primaryKeyColumns.Count > 1)
{
WriteLine(@" public interface I{0}Dao : IDao<{0}, {0}.DomainObjectID>", Helper.MakeSingle(Entity.Code));
}
else
{
WriteLine(@" public interface I{0}Dao : IDao<{0}, {1}>", Helper.MakeSingle(Entity.Code), primaryKeyColumns[0].NetDataType );
}
WriteLine(@" {");
WriteLine(@"");
WriteLine(@" }");
WriteLine(@"}");
}
else
{
WriteLine(@"//-- Entity " + Entity.Name + " does not have a primary key.");
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Danilo is the creator of
SmartRules, a Business Rules Engine. He is an industry consultant working primarily with companies interested in implementing dynamic rules programming concepts to add flexibility to their architectures on web, CE, and desktop platforms. He operates his own website,
Kontac, where you will find more information.
To contact Danilo, email him at danilo.mendez@gmail.com.