Exemplo n.º 1
0
        public void RespectsFieldNameFormatterOverrides()
        {
            var builder = new TsModelBuilder();

            builder.Add <DifferentNamespaces_Class2>();

            var generator = new TsGenerator();

            // Reverse the order of the properties
            generator.SetIdentifierFormatter(x => x.Name == "Property1" ? "propz" : "propa");
            var model = builder.Build();

            var result = generator.Generate(model);

            Assert.True(result.IndexOf("propa") < result.IndexOf("propz"), "Didn't order properties when formatters involved");
        }
Exemplo n.º 2
0
        private static string CompileModels(List <Type> types)
        {
            var builder = new TsModelBuilder();

            types.ForEach(a => builder.Add(a));

            var model = builder.Build();

            var generator = new TsGenerator();

            generator.IndentationString = "    ";
            generator.SetTypeVisibilityFormatter((tsClass, typeName) => true);
            generator.SetModuleNameFormatter((module) => "");
            generator.SetIdentifierFormatter((identifier) => Char.ToLower(identifier.Name[0]) + identifier.Name.Substring(1));

            string typeScript = generator.Generate(model);

            return(typeScript);
        }