public static ServerFile Load(string fileName) { ServerFile serv = new ServerFile(); string[] fileContents = null; try { fileContents = File.ReadAllLines(fileName); if (fileContents.Length < 7) throw new InvalidOperationException("Invalid update file format."); // TODO: More robust format checking? } catch (Exception) { throw; } serv.VersionChoices.Add(new VersionChoice()); serv.NewVersion = fileContents[0]; serv.MinClientVersion = fileContents[1]; VersionChoice version = new VersionChoice() { //InstallingTo = InstallingTo.BaseDir | InstallingTo.CommonAppData, InstallingTo = InstallingTo.BaseDir, Version = fileContents[2].Trim() }; bool changelogSection = true; for (int i = 3; i < fileContents.Length; i++) { if (!string.IsNullOrWhiteSpace(fileContents[i])) { if (!changelogSection) // Add dependent file version.FileSites.Add(fileContents[i].Trim()); else // Add to the changelog version.Changes += fileContents[i] + "\n"; } else { changelogSection = !changelogSection; } } serv.VersionChoices.Clear(); serv.VersionChoices.Add(version); serv.NoUpdateToLatestLinkText = "No applicable updates were found. Please update manually."; serv.NoUpdateToLatestLinkURL = "https://github.com/chances/Animatum/releases"; return serv; }
public static ServerFile Load(string fileName) { ServerFile serv = new ServerFile(); string[] fileContents = null; try { fileContents = File.ReadAllLines(fileName); if (fileContents.Length < 7) { throw new InvalidOperationException("Invalid update file format."); } // TODO: More robust format checking? } catch (Exception) { throw; } serv.VersionChoices.Add(new VersionChoice()); serv.NewVersion = fileContents[0]; serv.MinClientVersion = fileContents[1]; VersionChoice version = new VersionChoice() { //InstallingTo = InstallingTo.BaseDir | InstallingTo.CommonAppData, InstallingTo = InstallingTo.BaseDir, Version = fileContents[2].Trim() }; bool changelogSection = true; for (int i = 3; i < fileContents.Length; i++) { if (!string.IsNullOrWhiteSpace(fileContents[i])) { if (!changelogSection) // Add dependent file { version.FileSites.Add(fileContents[i].Trim()); } else // Add to the changelog { version.Changes += fileContents[i] + "\n"; } } else { changelogSection = !changelogSection; } } serv.VersionChoices.Clear(); serv.VersionChoices.Add(version); serv.NoUpdateToLatestLinkText = "No applicable updates were found. Please update manually."; serv.NoUpdateToLatestLinkURL = "https://github.com/chances/Animatum/releases"; return(serv); }