예제 #1
0
        public TemplateFileGeneratorPlugin(IGenerator generator, string templateYaml)
        {
            this.generator    = generator;
            this.methods      = new Dictionary <string, List <CallTemplate> > {
            };
            this.fields       = new Dictionary <string, FieldAccessTemplate> {
            };
            this.modelGlobals = new Dictionary <string, IVMValue> {
            };
            var root     = OneYaml.load(templateYaml);
            var exprDict = root.dict("expressions");

            if (exprDict == null)
            {
                return;
            }

            foreach (var exprStr in Object.keys(exprDict))
            {
                var val      = exprDict.get(exprStr);
                var tmplOnly = val.type() == ValueType.String;
                var ifStr    = tmplOnly ? null : val.str("if");
                var ifExpr   = ifStr == null ? null : new TypeScriptParser2(ifStr, null).parseExpression();
                var tmpl     = tmplOnly ? new CodeTemplate(val.asStr(), new string[0], null) : new CodeTemplate(val.str("template"), val.strArr("includes"), ifExpr);

                this.addExprTemplate(exprStr, tmpl);
            }
        }
 public ImplementationPackage(PackageContent content)
 {
     this.content            = content;
     this.implementations    = new List <ImplPkgImplementation>();
     this.implementationYaml = ImplPackageYaml.fromYaml(OneYaml.load(content.files.get("package.yaml")));
     this.implementations    = new List <ImplPkgImplementation>();
     foreach (var impl in this.implementationYaml.implements_ ?? new ImplPkgImplementation[0])
     {
         this.implementations.push(impl);
     }
     foreach (var include in this.implementationYaml.includes ?? new string[0])
     {
         var included = ImplPackageYaml.fromYaml(OneYaml.load(content.files.get(include)));
         foreach (var impl in included.implements_)
         {
             this.implementations.push(impl);
         }
     }
 }
예제 #3
0
 public ProjectTemplate(string templateDir)
 {
     this.templateDir = templateDir;
     this.meta        = ProjectTemplateMeta.fromYaml(OneYaml.load(OneFile.readText($"{templateDir}/index.yaml")));
     this.srcFiles    = OneFile.listFiles($"{templateDir}/src", true);
 }
 public InterfacePackage(PackageContent content)
 {
     this.content       = content;
     this.interfaceYaml = InterfaceYaml.fromYaml(OneYaml.load(content.files.get("interface.yaml")));
     this.definition    = content.files.get(this.interfaceYaml.definitionFile);
 }