Beispiel #1
0
        static void Main(string[] args)
        {
            const string source = @"

let id = Guid Id;

Security			  (id, string path)

let security = Security Security;

let name = string Name;
let rank = int Rank;
let parent = Guid ParentId;


DeleteContext	?(id)
ContextDeleted	!(id)

CreateContext	?(id, name, rank) 
ContextCreated	!(id, name, rank)";

            var generator = new TemplatedGenerator()
            {
            };

            Console.WriteLine(GeneratorUtil.Build(source, generator));

            Console.ReadLine();
        }
Beispiel #2
0
        public void Test()
        {
            var generator = new TemplatedGenerator()
            {
                Namespace = "Mine"
            };

            var dsl = @"

let name = string Name;
let security = SecurityDetails Security;
let auth = SecurityRequest Request;


entity ProjectAggregate (Guid ProjectId);
using ? = CommandTo<ProjectId>;
using ! = EventFrom<ProjectId>;




// projects
CreateProject? (name, int Rank, auth)
ProjectCreated! (name, int Rank, security)

RenameProject? (name, auth)
ProjectRenamed! (name, security)

DeleteProject? (auth)
ProjectDeleted! (ref DeleteProject)

entity null ();

DoSomething (name)

";
            var ctx = GeneratorUtil.GenerateContext(dsl);

            Console.WriteLine(GeneratorUtil.Build(ctx, generator));
        }
Beispiel #3
0
        static void Rebuild(string text, string fullPath)
        {
            var dsl = text;
            var generator = new TemplatedGenerator()
                {
                    Namespace = "Sample",
                    GenerateInterfaceForEntityWithModifiers = "?",
                    TemplateForInterfaceName = "public interface I{0}Aggregate",
                    TemplateForInterfaceMember = "void When({0} c);",
                    ClassNameTemplate = @"

            [DataContract(Namespace = ""Sample"")]
            public partial class {0}",
                    MemberTemplate = "[DataMember(Order = {0})] public {1} {2} {{ get; private set; }}",

                };

            var prefix = @"
            using System;
            using System.Collections.Generic;
            using System.Runtime.Serialization;

            ";
            File.WriteAllText(Path.ChangeExtension(fullPath, "cs"), prefix + GeneratorUtil.Build(dsl, generator));
        }