Exemplo n.º 1
0
        public static async Task <string> GenerateCodeAsync()
        {
            TestSite TestSite  = new TestSite("API");
            var      RouteInfo = TestSite.GetAllRouteInfo();

            return(GenerateRoutes(RouteInfo));
        }
Exemplo n.º 2
0
        public async Task <string> GenerateCodeAsync(CommondConfig config)
        {
            RouteGenerator.config = config;
            var routeInfos = new TestSite("Api").GetAllRouteInfo();

            return(GenerateRoutes(routeInfos));
        }
Exemplo n.º 3
0
        public async Task <string> GenerateCodeAsync(string projectName)
        {
            Console.WriteLine($"projectName: {projectName}");
            if (string.IsNullOrEmpty(projectName))
            {
                projectName = "*";
            }

            Console.WriteLine($"Environment.CurrentDirectory: {Environment.CurrentDirectory}");
            var projectFile = Directory.GetFiles(Environment.CurrentDirectory, $"{projectName}.csproj", SearchOption.AllDirectories).FirstOrDefault();

            if (projectFile == null)
            {
                throw new ArgumentException($"No .csproj file found under the directory: {projectName}.");
            }

            Console.WriteLine($"projectFile: {projectFile}");
            FileInfo file = new FileInfo(projectFile);

            Console.WriteLine($"file.Name: {file.Name}");
            var client = new TestSite(file.Name.Replace(".csproj", string.Empty)).BuildClient();

            using (HttpResponseMessage response = await client.GetAsync(Router.DefaultRoute))
            {
                string content = await response.Content.ReadAsStringAsync();

                return(GenerateRoutes(content));
            }
        }