예제 #1
0
        public ProjectionContext Transform(ProjectionContext context)
        {
            var modelManager = InputManager;

            var model = modelManager.Get(context.Input.Selector);
            if (model != null)
            {
                var input = new ProjectionInput(model);

                // this the generator impl

                GeneratorRegistry.TryGet(context.GeneratorName, out GeneratorDeclaration generatorDecl);

                var transformationRules = generatorDecl.Rules;

                var transformationOutput = new ModelToTextOutput();

                foreach (var tranformationRule in transformationRules)
                {
                    var templateEngine = TemplateEngineProvider.GetEngine(tranformationRule.TemplateLanguage);
                    var transformationOutputFile = templateEngine.Transform(context, input, tranformationRule);
                    transformationOutput.AddOutputFile(transformationOutputFile);
                }

                // end gen impl

                context.Output = transformationOutput;

                AppTrace.Information("Projection completed.");
            }

            return context;
        }
예제 #2
0
 public TextTemplate GetFile(ProjectionContext context, TransformationRuleDeclaration file)
 {
     if (file.IsEmbedded)
     {
         return(TextTemplate.Create(file, GetResourceStream(file.TemplateName)));
     }
     else
     {
         return(TextTemplate.Create(file, ResolveRulePath(context, file)));
     }
 }
예제 #3
0
        protected string ResolveRulePath(ProjectionContext context, TransformationRuleDeclaration rule)
        {
            var requestedFile = rule.TemplateName;

            return(requestedFile);
        }