Ejemplo n.º 1
0
        public override async Task Generate(RestApiSpec spec, ProgressBar progressBar, CancellationToken token)
        {
            // Delete existing files
            foreach (var file in Directory.GetFiles(GeneratorLocations.NestFolder, "ElasticClient.*.cs"))
            {
                File.Delete(file);
            }

            var view   = ViewLocations.HighLevel("Client", "Implementation", "ElasticClient.cshtml");
            var target = GeneratorLocations.HighLevel($"ElasticClient.{CsharpNames.RootNamespace}.cs");

            await DoRazor(spec, view, target, null, token);

            string Target(string id) => GeneratorLocations.HighLevel($"ElasticClient.{id}.cs");

            var namespaced    = spec.EndpointsPerNamespaceHighLevel.Where(kv => kv.Key != CsharpNames.RootNamespace).ToList();
            var dependantView = ViewLocations.HighLevel("Client", "Implementation", "ElasticClient.Namespace.cshtml");

            await DoRazorDependantFiles(progressBar, namespaced, dependantView, kv => kv.Key, id => Target(id), token);
        }
        public override async Task Generate(RestApiSpec spec, ProgressBar progressBar, CancellationToken token)
        {
            // Delete existing files
            foreach (var file in Directory.GetFiles(GeneratorLocations.NestFolder, "Requests.*.cs"))
            {
                File.Delete(file);
            }

            var view   = ViewLocations.HighLevel("Requests", "PlainRequestBase.cshtml");
            var target = GeneratorLocations.HighLevel("Requests.cs");

            await DoRazor(spec, view, target, null, token);

            var dependantView = ViewLocations.HighLevel("Requests", "Requests.cshtml");

            string Target(string id) => GeneratorLocations.HighLevel($"Requests.{id}.cs");

            var namespaced = spec.EndpointsPerNamespaceHighLevel.ToList();

            await DoRazorDependantFiles(progressBar, namespaced, dependantView, kv => kv.Key, id => Target(id), token);
        }