Exemplo n.º 1
0
        /****************************************************************************/
        private static void TransformFile(JTran.Transformer transformer, string sourceFile, string output, TransformerContext context)
        {
            var result = transformer.Transform(sourceFile, context);
            var path   = output;

            if (string.IsNullOrWhiteSpace(Path.GetExtension(output)))
            {
                path = Path.Combine(output, Path.GetFileName(sourceFile));
            }

            File.WriteAllText(path, result);
        }
Exemplo n.º 2
0
        /****************************************************************************/
        public string Transform(string source, string transform)
        {
            var transformer = new JTran.Transformer(transform, includeSource: new FileIncludeRepository(_preferences.IncludePath));

            var context = new TransformerContext();

            context.DocumentRepositories = new DocumentsRepository(_preferences.DocumentPath);

            var result  = transformer.Transform(source, context);
            var expando = result.JsonToExpando() as ExpandoObject;

            return(_formatter.Format(expando));
        }