Utils.cs 591 B

123456789101112131415161718192021222324252627
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace Fuel01
  9. {
  10. public static class Utils
  11. {
  12. public static bool SaveToJson<T>(string filename, T ds)
  13. {
  14. try
  15. {
  16. var result = JsonConvert.SerializeObject(ds,Formatting.Indented);
  17. File.WriteAllText(filename, result);
  18. return true;
  19. }
  20. catch
  21. {
  22. return false;
  23. }
  24. }
  25. }
  26. }