Example #1
0
        public static void Generate <T>(string route, string outputPath)
            where T : class
        {
            var settings  = new SigSpecGeneratorSettings();
            var generator = new SigSpecGenerator(settings);
            var document  = generator.GenerateForHubsAsync(new Dictionary <string, Type>
            {
                { "route".Trim('/'), typeof(T) }
            }).GetAwaiter().GetResult();

            var codeGeneratorSettings = new SigSpecToJavaScriptGeneratorSettings();
            var codeGenerator         = new SigSpecToJavaScriptGenerator(codeGeneratorSettings);
            var file = codeGenerator.GenerateFile(document);

            File.WriteAllText(outputPath, file);
        }
Example #2
0
        static async Task RunAsync()
        {
            var settings  = new SigSpecGeneratorSettings();
            var generator = new SigSpecGenerator(settings);

            // TODO: Add PR to SignalR Core with new IHubDescriptionCollectionProvider service
            var document = await generator.GenerateForHubsAsync(new Dictionary <string, Type>
            {
                { "progress", typeof(ProgressHub) }
            });

            //var json = document.ToJson();
            //Console.WriteLine("\nGenerated SigSpec document:");
            //Console.WriteLine(json);
            //Console.ReadKey();

            var codeGeneratorSettings = new SigSpecToJavaScriptGeneratorSettings();
            var codeGenerator         = new SigSpecToJavaScriptGenerator(codeGeneratorSettings);
            var file = codeGenerator.GenerateFile(document);

            Console.WriteLine("Generated SigSpec JavaScript code:\n\n");
            Console.WriteLine(file);
            Console.ReadKey();
        }