Esempio n. 1
0
        private static void Main(string[] args)
        {
            var context = new GeneratorContext()
            {
                NameFormatter = type => type.IsEnum ? type.Name : "I" + type.Name,
                TightOptional = false,
                ModelsPath    = "./models",
            };
            var genModels  = new BackendModelsGenerator(context);
            var genBackend = new BackendGenerator(context)
            {
                Header =
                {
                    "import { call } from 'redux-saga/effects';",
                    "import { apiCall } from './api';",
                },
            };

            // context.ReferencedTypes.Add(typeof());

            var backend = genBackend.Generate(Assembly.GetExecutingAssembly());

            File.WriteAllText("backend.ts", backend);
            Console.WriteLine(backend);

            var models = genModels.Generate();

            File.WriteAllText("models.ts", models);
            Console.WriteLine(models);
        }
Esempio n. 2
0
        public void BackendModel()
        {
            var gen    = new BackendModelsGenerator(_ctxBackend);
            var result = gen.Generate();

            result = result.Replace("\n", "").Trim();
            Assert.IsTrue(result.Contains("export interface TOther {tClass?: TClass;number: number;nNumber?: number | null;text?: string;boolean: boolean;}"));
        }