static int Main(string[] args) { if (args.Length != 4) { Console.WriteLine("Expected arguments: <JSON file> <output directory> <features file> <enum storage file>"); return(1); } string json = File.ReadAllText(args[0]); string outputDirectory = args[1]; string featuresJson = File.ReadAllText(args[2]); string enumStorageFile = args[3]; string enumStorageJson = File.Exists(enumStorageFile) ? File.ReadAllText(enumStorageFile) : "{}"; var enumStorage = PackageEnumStorage.FromJson(enumStorageJson); var features = JsonConvert.DeserializeObject <Features>(featuresJson); var files = CodeGenerator.Generate(json, features, enumStorage); foreach (var file in files) { var path = Path.Combine(outputDirectory, file.RelativePath); Directory.CreateDirectory(Path.GetDirectoryName(path)); File.WriteAllText(path, file.Content); } File.WriteAllText(enumStorageFile, enumStorage.ToJson()); return(0); }
public static IEnumerable <ResultFile> Generate(string discoveryJson, Features features, PackageEnumStorage enumStorage) { discoveryJson = NormalizeDescriptions(discoveryJson); var discoveryDescription = NewtonsoftJsonSerializer.Instance.Deserialize <RestDescription>(discoveryJson); var package = new PackageModel(discoveryDescription, features, enumStorage); yield return(GenerateCSharpCode(package)); yield return(GenerateProjectFile(package)); yield return(GenerateNet40Config(package)); yield return(GenerateNetStandard10Config(package)); }