Esempio n. 1
0
 protected override void RunCore()
 {
     if (LoadConfiguration())
     {
         List <Exception> exs = new List <Exception>();
         try
         {
             foreach (ContractServiceDefinition Interface in _Configuration.ContractServiceInterfaces)
             {
                 ClassTemplate template = new ClassTemplate();
                 template.Class       = (ContractServiceClassDefinition)Interface;
                 template.Output.File = String.Format(@"{0}.cs", template.Class.Name);
                 template.Render();
             }
         }
         catch (Exception ex)
         {
             exs.Add(ex);
         }
         if (exs.Count > 0)
         {
             ErrorTemplate errortemplate = new ErrorTemplate();
             ErrorTemplate.Exceptions  = exs;
             errortemplate.Output.File = "Error.log";
             errortemplate.Render();
             throw new Exception("See generated output for errors.");
         }
     }
 }
Esempio n. 2
0
 protected override void RunCore()
 {
     if (LoadConfiguration())
     {
         List <Exception> exs = new List <Exception>();
         try
         {
             foreach (var item in _Configuration.DomainObjectClasses)
             {
                 ClassTemplate template = new ClassTemplate();
                 template.Class       = item;
                 template.Output.File = String.Format(@"{0}.cs", item.Name);
                 template.Render();
             }
         }
         catch (Exception ex)
         {
             exs.Add(ex);
         }
         if (exs.Count > 0)
         {
             ErrorTemplate errortemplate = new ErrorTemplate();
             ErrorTemplate.Exceptions = exs;
             errortemplate.Render();
             throw new Exception("See generated output for errors.");
         }
     }
 }
Esempio n. 3
0
        private TypeGeneratorResult GenerateClass(string typeName)
        {
            var properties = _schema.Properties.Values
                             .Select(property => new PropertyModel(property, _resolver, Settings))
                             .ToList();

            var template = new ClassTemplate() as ITemplate;

            template.Initialize(new ClassTemplateModel(typeName, Settings, _resolver, _schema, properties));
            return(new TypeGeneratorResult
            {
                TypeName = typeName,
                Code = template.Render()
            });
        }
Esempio n. 4
0
        private TypeGeneratorResult GenerateClass(string typeName)
        {
            var properties = _schema.AllProperties.Values
                             .Where(p => !p.IsInheritanceDiscriminator)
                             .Select(property => new PropertyModel(property, _resolver, Settings))
                             .ToList();

            RenamePropertyWithSameNameAsClass(typeName, properties);

            var model    = new ClassTemplateModel(typeName, Settings, _resolver, _schema, properties);
            var template = new ClassTemplate() as ITemplate;

            template.Initialize(model);
            return(new TypeGeneratorResult
            {
                TypeName = typeName,
                BaseTypeName = model.BaseClass,
                Code = template.Render()
            });
        }
Esempio n. 5
0
        private static void GenerateFor(string outputDir, EngineApi engineApi, EngineClass @class)
        {
            string scope = (string.IsNullOrEmpty(@class.Scope) ? "Global" : @class.Scope);

            var scriptObject = new ScriptObject();

            scriptObject.Add("class", @class);
            scriptObject.Add("scope", scope);

            string output = ClassTemplate.Render(@class, scope);

            string dir = $"{outputDir}/Classes/{scope.Replace('.', '/')}";

            Console.WriteLine($"{dir}/{@class.Name}.cs");

            Directory.CreateDirectory(dir);

            using (StreamWriter SW = new StreamWriter($"{dir}/{@class.Name}.cs")
                   ) {
                SW.Write(output);
            }
        }