/// <summary> /// /// </summary> public void RemoveRepoDetails(RepoDetails sd) { if (sd == null) { return; } int l = details.Count - 1; for (; l >= 0; l--) { RepoDetails sdr = details[l]; if (sd.GetHashCode() == sdr.GetHashCode()) { details.RemoveAt(l); return; } } }
/// <summary> /// Load a server file into memory /// </summary> public void LoadFile(string path) { if (!File.Exists(path)) { FileUtil.WriteToFileUTF8(ApplicationConstant.PATH_REPO, null); return; } string[] lines = File.ReadAllLines(path); RepoDetails detail = null; foreach (string line in lines) { if (line.Length < 1) { continue; } if (line.Substring(0, 1).Equals("#")) { AddRepoDetails(detail, true); detail = new RepoDetails(); detail.SetName(line.Substring(1)); } if (detail == null) { continue; } string sub = line.Substring(0, 2); if (sub.Equals("s:")) { detail.SetServer(line.Substring(2)); } if (sub.Equals("r:")) { detail.SetRemote(line.Substring(2)); } if (sub.Equals("l:")) { detail.SetLocal(line.Substring(2)); } } AddRepoDetails(detail, true); }
/// <summary> /// /// </summary> public void AddRepoDetails(RepoDetails sd, bool overwrite) { if (sd == null) { return; } var detail = GetRepoDetailsByName(sd.GetName()); if (detail != null) { if (!overwrite) { return; } detail.SetName(sd.GetName()); detail.SetServer(sd.GetServer()); detail.SetRemote(sd.GetRemote()); detail.SetLocal(sd.GetLocal()); return; } details.Add(sd); WriteFile(ApplicationConstant.PATH_REPO); }
/// <summary> /// /// </summary> public void SetSelected(RepoDetails sd) { selected = sd; }
/// <summary> /// private singleton constructor /// </summary> private ReposConfig() { details = new List <RepoDetails>(); selected = null; utf8WithoutBom = new UTF8Encoding(false); }