Ejemplo n.º 1
0
        /// <summary>Generates the file.</summary>
        /// <returns>The file contents.</returns>
        public override string GenerateFile()
        {
            var output =
                GenerateType(_resolver.GenerateTypeName()).Code + "\n\n" +
                _resolver.GenerateTypes() + "\n\n" +
                Settings.TransformedExtensionCode + "\n\n";

            return(ConversionUtilities.TrimWhiteSpaces(output));
        }
Ejemplo n.º 2
0
        /// <summary>Generates the file.</summary>
        /// <param name="rootTypeNameHint">The root type name hint.</param>
        /// <returns>The file contents.</returns>
        public override string GenerateFile(string rootTypeNameHint)
        {
            _resolver.Resolve(_schema, false, rootTypeNameHint); // register root type

            var extensionCode = new TypeScriptExtensionCode(Settings.ExtensionCode, Settings.ExtendedClasses);
            var model         = new FileTemplateModel(Settings)
            {
                Types         = ConversionUtilities.TrimWhiteSpaces(_resolver.GenerateTypes(extensionCode)),
                ExtensionCode = extensionCode
            };

            var template = Settings.TemplateFactory.CreateTemplate("TypeScript", "File", model);

            return(ConversionUtilities.TrimWhiteSpaces(template.Render()));
        }
Ejemplo n.º 3
0
        /// <summary>Generates the file.</summary>
        /// <returns>The file contents.</returns>
        public override string GenerateFile()
        {
            _resolver.Resolve(_schema, false, string.Empty); // register root type

            var model = new FileTemplateModel(Settings)
            {
                Types = ConversionUtilities.TrimWhiteSpaces(_resolver.GenerateTypes(Settings.ProcessedExtensionCode)),

                ExtensionCodeBefore = Settings.ProcessedExtensionCode.CodeBefore,
                ExtensionCodeAfter  = Settings.ProcessedExtensionCode.CodeAfter
            };

            var template = Settings.TemplateFactory.CreateTemplate("TypeScript", "File", model);

            return(ConversionUtilities.TrimWhiteSpaces(template.Render()));
        }
Ejemplo n.º 4
0
        /// <summary>Generates the file.</summary>
        /// <returns>The file contents.</returns>
        public override string GenerateFile()
        {
            _resolver.Resolve(_schema, false, string.Empty); // register root type

            var template = new FileTemplate() as ITemplate;

            template.Initialize(new FileTemplateModel
            {
                Types = ConversionUtilities.TrimWhiteSpaces(_resolver.GenerateTypes(Settings.ProcessedExtensionCode)),

                HasModuleName = !string.IsNullOrEmpty(Settings.ModuleName),
                ModuleName    = Settings.ModuleName,

                ExtensionCodeBefore = Settings.ProcessedExtensionCode.CodeBefore,
                ExtensionCodeAfter  = Settings.ProcessedExtensionCode.CodeAfter
            });
            return(ConversionUtilities.TrimWhiteSpaces(template.Render()));
        }
Ejemplo n.º 5
0
 /// <summary>Generates the file.</summary>
 /// <returns>The file contents.</returns>
 public override string GenerateFile()
 {
     return(GenerateType(string.Empty).Code + "\n\n" + _resolver.GenerateTypes());
 }