public override void SaveWorkspace() { var config = GetConfigFromUI(); string wsDirectory = ProgramUI.GetWorkspaceDirectory(); if (!Directory.Exists(wsDirectory)) { Directory.CreateDirectory(wsDirectory); } if (string.IsNullOrEmpty(this.filename)) { this.filename = RESTConfig.GetWorkspaceFilename(); } string json = JsonConvert.SerializeObject(config, Formatting.Indented, new JsonSerializerSettings { Converters = new List <JsonConverter> { new StringEnumConverter() }, NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.Indented, DefaultValueHandling = DefaultValueHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Ignore, PreserveReferencesHandling = PreserveReferencesHandling.Objects, ContractResolver = new CamelCasePropertyNamesContractResolver() }); File.WriteAllText(this.filename, json, Encoding.UTF8); }
internal void LoadConfigFromJSON(string filename) { this.filename = filename; RESTConfig config = JsonConvert.DeserializeObject <RESTConfig>(File.ReadAllText(filename)); SetTextFromSettings(config.HostUrl, this.tbHost); SetTextFromSettings(config.Path, this.cbPath); // this.cbMode.SelectedIndex = (int)config.OperatMode; SetTextFromSettings(config.Login, this.tbLogin); SetTextFromSettings(config.Password, this.tbPassword); ShowPanels(); }
public override IConfigService GetConfigFromUI() { RESTConfig conf = new RESTConfig { // conf.OperatMode = opEnum; HostUrl = tbHost.Text, Path = cbPath.Text, // int listSize = 10; // conf.ListSize = listSize; Login = tbLogin.Text, Password = tbPassword.Text }; return(conf); }