public static async Task ExportToJson(DataSharingPolciy dataSharingPolicy, string fileName) { using (StreamWriter r = new StreamWriter(fileName)) { await r.WriteAsync(JToken.Parse(ExportToJsonString(dataSharingPolicy)).ToString(Formatting.Indented)); } }
public static string ExportToJsonString(DataSharingPolciy dataSharingPolciy) { if (dataSharingPolciy.JsonCompositeContex == null) { dataSharingPolciy.JsonCompositeContex = dataSharingPolciy.CompositeContex.GenreateJsonVersion(); } string jsonString = JsonConvert.SerializeObject(dataSharingPolciy, typeof(DataSharingPolciy), _settings); return(jsonString); }