Esempio n. 1
0
        private static void CreateTypeScriptServices(ApplicationPartManager applicationPartManager)
        {
            ControllerFeature feature = new ControllerFeature();

            applicationPartManager.PopulateFeature(feature);
            var controllerTypes = feature.Controllers.Select(c => c.AsType());
            var converter       = new Converter();
            var assembly        = converter.ReadControllers(controllerTypes);
            var typeScript      = new TypeScriptWriter();

            typeScript.WriteAssembly(assembly);
            typeScript.WriteToFiles("src/services");
        }
Esempio n. 2
0
        private static void CreateTypeScriptServices(ApplicationPartManager applicationPartManager)
        {
            ControllerFeature feature = new ControllerFeature();

            applicationPartManager.PopulateFeature(feature);
            var controllerTypes = feature.Controllers.Select(c => c.AsType());
            var converter       = new Converter();
            var assembly        = converter.ReadControllers(controllerTypes);
            var typeScript      = new TypeScriptWriter(options: TypeScriptOptions.ParametersInObject);

            // Call WriteAssembly twice; once for KO mappings, once for TS
            typeScript.WriteAssembly(assembly, false);
            typeScript.WriteAssembly(assembly, true);
            typeScript.WriteToFiles("src/services");
        }
        private static void CreateTypeScriptServices(ApplicationPartManager applicationPartManager, bool useKnockout, string outputDir)
        {
            ControllerFeature feature = new ControllerFeature();

            applicationPartManager.PopulateFeature(feature);
            var controllerTypes = feature.Controllers.Select(c => c.AsType());
            var converter       = new Converter();
            var assembly        = converter.ReadControllers(controllerTypes);
            var typeScript      = new TypeScriptWriter();

            // Call WriteAssembly twice ; once for TypeScript objects and once for Knockout mappings
            if (useKnockout)
            {
                typeScript.WriteAssembly(assembly, true);
            }
            typeScript.WriteAssembly(assembly, false);
            typeScript.WriteToFiles(outputDir);
        }