public FileResult Post(List <IFormFile> files) { List <Model> Models = new List <Model>(); long size = files.Sum(f => f.Length); try { var filePath = Path.GetTempFileName(); foreach (var formFile in files) { if (formFile.Length > 0) { using (var reader = new StreamReader(formFile.OpenReadStream())) { string text = reader.ReadToEnd(); reader.Dispose(); string[] models = text.Split(new string[] { "class" }, StringSplitOptions.None); for (int i = 1; i < models.Length; i++) { Model m = new Model(models[i], "Test"); Models.Add(m); } } } } string fileName = "Project.txt"; byte[] bytes = new byte[0]; MemoryStream ms = new MemoryStream(); TextWriter tw = new StreamWriter(ms); List <string> downloads = new List <string>(); foreach (Model m in Models) { tw.WriteLine(APIControllerGenerator.Generate(m)); tw.WriteLine(RepositoryGenerator.Generate(m)); tw.WriteLine(ServiceGenerator.Generate(m)); tw.WriteLine(TableGenerator.Generate(m, Models)); } tw.Flush(); bytes = ms.ToArray(); ms.Dispose(); return(File(bytes, "application/x-msdownload", fileName)); } catch (Exception ex) { return(File("", "")); } }
private static void Main() { var assembly = typeof (IInfusionSoftConfiguration).Assembly; var generator = new ServiceGenerator(assembly) { InterfaceDirectory = Path.Combine(Output, ".").Directory(), WrapperDirectory = Path.Combine(Output, "Wrappers").Directory() }; Service[] services = generator.Generate(); Console.Out.WriteLine("{0} services created", services.Length); Console.Out.WriteLine("done"); Console.ReadKey(); }
static void Main(string[] args) { var map = new Dictionary<string, string>(StringComparer.Ordinal); var key = (string)null; foreach (var item in args) { if (item.Length == 0) continue; if (item.StartsWith("-", StringComparison.Ordinal)) key = item; else if (key != null) map[key] = $"{(map.TryGetValue(key, out var value) ? value + " " : string.Empty)}{item.Trim(' ', '\'', '\"')}"; } if (!map.TryGetValue("-p", out var path) && !map.TryGetValue("--path", out path)) { throw new ArgumentException("Path missing, expect -p|--path path1 path2"); } if (!map.TryGetValue("-o", out var output) && !map.TryGetValue("--out", out output)) { throw new ArgumentException("Out missing, expect -o|--out path1 path2"); } if (!map.TryGetValue("-n", out var nameSpace) && !map.TryGetValue("--namespace", out nameSpace)) { //throw new ArgumentException("Nmaespace missing, expect -n|--namespace Name.Space"); } CodeGeneratorMode mode = CodeGeneratorMode.Controllers; if (map.TryGetValue("-m", out var modeText) || map.TryGetValue("--mode", out modeText)) { if (!Enum.TryParse<CodeGeneratorMode>(modeText, out mode)) throw new ArgumentException("Mode missing, expect -m|--mode Controllers|,|Logs|,|Invokers"); } var generator = new ServiceGenerator(path, output, nameSpace); generator.Mode = mode; generator.Generate(); generator.GetUnits(true); }