Skip to content

Code Generation

sam.gerene edited this page Aug 4, 2022 · 4 revisions

Code Generation

The purpose of KAlliope is to support convention-based and template-based code generation. Multiple templating engines are available in the .NET ecosystem such as DotLiquid and Handlebars.NET. More temaplating engines exist and of course they can be used as well, the reason to use one is basicaly determined by "what you like best".

A part of the Kalliope library has been code-generated using DotLiquid, read more about it [here|Kalliope-Code-Generation]

Codegeneration can be used to generate anything that is relevant to your project, it can include generation of the following kinds of concepts:

  • HTML
  • C# code such as classes, interfaces, enumerations, structs, etc.
  • XML Schema
  • SQL Schema, SQL queries, etc
  • Graph Schema and Graph queries such as Cypher, SPARQL, etc.
  • Object Relational Mappings (not to be confused with Object Role Modelling)

The first step in code generation is to read an ORM model and to have it available as an object graph in memory. This is done using the OrmFileReader. The following code-snippet demonstrates how this is done:

    var ormXmlReader = new OrmXmlReader();
    var fileReader = new OrmFileReader
    {
        OrmXmlReader = ormXmlReader
    };

    var path = "path-to-an-orm-model";

    fileReader.Read(path);

    var cache = this.fileReader.Assembler.Cache;
    Lazy<Kalliope.Core.ModelThing> lazyPoco;
    cache.TryGetValue("root:unique-identifier-of-the-root-model-entity", out lazyPoco);
    var ormRoot = (Kalliope.OrmRoot)lazyPoco.Value;

The ormRoot variable in the above code-snippet is the ORM Model class which provides access to the content of the model such all the EntityTypes, ValueTypes, etc.

DotLquid

MORE COMING SOON

Handlebars.NET

MORE COMING SOON

Kalliope

  1. Home
  2. Documentation Overview
  3. Quick Start
  4. Roadmap

Soultion Structure

  1. Solution Structure

Kalliope Data Model

  1. The Data Model
  2. Kalliope Attributes
  3. Code Generation

Kalliope ORM to OO

  1. Intermediate OO classes

Code Generation with Kalliope

  1. Code Generation

Developer Environment

  1. Developers Experience
  2. Build and Release
Clone this wiki locally