public static Settings FromFile(string filename) { if (String.IsNullOrEmpty(filename)) { throw new ArgumentNullException(nameof(filename)); } if (!Common.FileExists(filename)) { throw new FileNotFoundException(nameof(filename)); } string contents = Common.ReadTextFile(@filename); Settings ret = Common.DeserializeJson <Settings>(contents); return(ret); }
public static T CopyObject <T>(T source) { if (source == null) { return(default(T)); } string json = SerializeJson(source); try { return(Common.DeserializeJson <T>(json)); } catch (Exception) { return(default(T)); } }
/// <summary> /// Load settings from file. /// </summary> /// <param name="filename">Filename and path.</param> /// <returns>Settings.</returns> public static Settings FromFile(string filename) { return(Common.DeserializeJson <Settings>(Common.ReadTextFile(filename))); }