Skip to content

VictordeBaare/Tobasco

Repository files navigation

Tobasco

Easy to use generator for your entities

How do you use it?

Tobasco features a couple of default builders for a quick start. These builder can be used to generate basic entity classes, database tables and CRUD stored procedures, repositories, Ninject module and mapping between generated entities.

T4

To use Tobasco to generate your classes, first add a T4 template. In the T4 template add the following lines of code:

<#@ template debug="true" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="$(SolutionDir)LocationOffDll\Tobasco.dll" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".cs" #>
<#@ import namespace="Tobasco" #>
<#@ import namespace="Tobasco.Manager" #>
<#@ import namespace="Tobasco.Enums" #>
<#
	var processor = FileProcessor.Create(this);    

	processor.BeginProcessing(Host.ResolvePath(string.Empty));
#>

The Host.ResolvePath(string.Empty) is used to point to the location of your xmls. The xmls are the basis of your entity definition. In the current example the xml files are in the same directory and folder as the generator.

Xml definition

For your entity definitions you'll have to start with an MainInfo.xml file. This file describes the basic values for the entities. The basic values include:

  • EntityLocations
  • BaseNamespaces
  • Mappers
  • Database
  • Repository
  • DependencyInjection
  • ConnectionFactory
  • GenericRepository

EntityLocations

In the EntityLocations element you can add n locations in which you want to generate your entity. For example:

<?xml version="1.0" encoding="utf-8" ?>
<EntityInformation>
  <EntityLocations>
        <EntityLocation>
            <FileLocation project="TobascoTest" folder="GeneratedEntity"></FileLocation>
        </EntityLocation>
        <EntityLocation generaterules="true">
            <FileLocation project="TobascoTest" folder="GeneratedEntity2"></FileLocation>
        </EntityLocation>
    </EntityLocations>
</EntityInformation>

Using the example above entities will be generated in the project: 'TobascoTest' in the folders: 'GeneratedEntity' and 'GeneratedEntity2'. The second entry of 'EntityLocation' has also the following attribute 'generaterules="true"' this attribute will tell Tobasco to generate businessrules for this entity.

Additional elements which can be added to the 'EntityLocation' element are:

  • Namespaces
  • ORMapper
Example
<EntityLocation>
    <FileLocation project="TobascoTest" folder="GeneratedEntity"></FileLocation>
    <Namespaces>
        <Namespace value="System.Dynamic"></Namespace>
    </Namespaces>
    <ORMapper type="Dapper"></ORMapper>
</EntityLocation>

BaseNamespaces

The namespaces which should be added to every generated file.

Example
<EntityInformation>
    <BaseNamespaces>
        <Namespace value="System.Collections.Generic"></Namespace>
    </BaseNamespaces>
</EntityInformation>

Mappers

More information to follow.

Database

More information to follow.

Repository

More information to follow.

DependencyInjection

More information to follow.

ConnectionFactory

More information to follow.

GenericRepository

More information to follow.

Releases

No releases published

Packages

No packages published

Languages