private void SaveFile(string location, string name, object data, StoreProjectItemType type) { if (string.IsNullOrWhiteSpace(name)) { throw new Exception("File cannot have empty name"); } var file = name + "." + GetProjectItemExtension(type); file = Path.Combine(location, file); var json = JsonSerializer.Serialize(data, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(file, json); }
private string GetProjectItemExtension(StoreProjectItemType type) { switch (type) { case StoreProjectItemType.Project: return("project.json"); case StoreProjectItemType.Form: return("form.json"); case StoreProjectItemType.Query: return("query.json"); case StoreProjectItemType.Schema: return("schema.json"); } return(""); }