public static void SaveInterfaceSetting(List <NetworkInterface> model) { var n = new Network2ConfigurationModel { Interfaces = model }; Json.Save(n, CfgFile); ConsoleLogger.Error("[network] configuration saved"); }
public static bool Save(Network2ConfigurationModel conf) { var text = JsonConvert.SerializeObject(conf, Formatting.Indented); try { FileWithAcl.WriteAllText(CfgFile, text, "644", "root", "wheel"); } catch (Exception ex) { ConsoleLogger.Error($"[network] configuration save error: {ex.Message}"); return(false); } return(true); }
private static Network2ConfigurationModel Parse() { var conf = new Network2ConfigurationModel(); if (!File.Exists(CfgFile)) { return(conf); } try { var text = File.ReadAllText(CfgFile); conf = JsonConvert.DeserializeObject <Network2ConfigurationModel>(text); } catch (Exception) { conf = new Network2ConfigurationModel(); } return(conf); }