diff --git a/Katteker/ChangelogHelper.cs b/Katteker/ChangelogHelper.cs index 0c4fec4..22c1207 100644 --- a/Katteker/ChangelogHelper.cs +++ b/Katteker/ChangelogHelper.cs @@ -5,8 +5,17 @@ using System.Threading.Tasks; namespace Katteker { + /// + /// Helps handle the Changelog. + /// public static class ChangelogHelper { + /// + /// Format the Changelog as Html compilant file.s + /// + /// + /// + /// public static string ChangelogAsHtml(this string text, string extension) { string result; @@ -27,6 +36,12 @@ namespace Katteker return result; } + /// + /// Load changelog from Web or use the local file, if it fails. + /// + /// + /// + /// public static async Task LoadChangelogAsync(string filename, string path) { if (!string.IsNullOrEmpty(filename) || !string.IsNullOrEmpty(path)) diff --git a/Katteker/Properties/AssemblyInfo.cs b/Katteker/Properties/AssemblyInfo.cs index f69120d..ba3bb53 100644 --- a/Katteker/Properties/AssemblyInfo.cs +++ b/Katteker/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // indem Sie "*" wie unten gezeigt eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.3")] -[assembly: AssemblyFileVersion("1.0.3")] +[assembly: AssemblyVersion("1.0.4")] +[assembly: AssemblyFileVersion("1.0.4")] diff --git a/Katteker/ReleaseEntry.cs b/Katteker/ReleaseEntry.cs index 4d2888f..9c7f4a0 100644 --- a/Katteker/ReleaseEntry.cs +++ b/Katteker/ReleaseEntry.cs @@ -5,12 +5,18 @@ using Semver; namespace Katteker { + /// + /// Entry of a Release. + /// public class ReleaseEntry : IComparable, IComparable { private const string FilenameRegex = @"(^.*)-((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?).*-(full|delta)"; private const char Seperator = '|'; + /// + /// Construct a new release entry. + /// public ReleaseEntry(string filename, SemVersion version, long fileSize, bool isDelta, string sha1) { Filename = filename; @@ -20,6 +26,10 @@ namespace Katteker SHA1 = sha1; } + /// + /// Construct release entry from string. + /// + /// public ReleaseEntry(string line) { var elements = line?.Split(Seperator); @@ -34,23 +44,53 @@ namespace Katteker IsDelta = fileSegments.Groups[3].Value != "full"; } + /// + /// cunstruct release entry from application name and version. + /// + /// + /// public ReleaseEntry(string applicationName, SemVersion version) { ApplicationName = applicationName; Version = version; } + /// + /// Version + /// public SemVersion Version { get; } + /// + /// Hashsum of the file. + /// public string SHA1 { get; } + /// + /// filename + /// public string Filename { get; } + /// + /// Size of the file. + /// public long Filesize { get; } + /// + /// Is true if the update is delta file. False otherwise. + /// public bool IsDelta { get; } + /// + /// Name of the application. + /// public string ApplicationName { get; } + /// + /// Format the release entry as line for release file. + /// public string EntryAsString => $"{SHA1}{Seperator}{Filename}{Seperator}{Filesize}"; + /// public override string ToString() => $"{ApplicationName} {Version}"; + + /// public int CompareTo(object obj) => CompareTo(obj as ReleaseEntry); + /// public int CompareTo(ReleaseEntry other) { if (ReferenceEquals(this, other)) return 0; @@ -60,13 +100,20 @@ namespace Katteker return string.Compare(Filename, other.Filename, StringComparison.Ordinal); } + /// public override bool Equals(object obj) => Equals(obj as ReleaseEntry); + /// + /// Returns true if the instances are equal. False otherwise. + /// + /// + /// protected bool Equals(ReleaseEntry other) { return Equals(Version, other.Version) && string.Equals(SHA1, other.SHA1) && string.Equals(Filename, other.Filename) && Filesize == other.Filesize && IsDelta == other.IsDelta; } + /// public override int GetHashCode() { unchecked @@ -80,14 +127,14 @@ namespace Katteker } } - public static bool operator ==(ReleaseEntry left, ReleaseEntry right) - { - return Equals(left, right); - } + /// + /// Returns true if the left and right instances are equal. + /// + public static bool operator ==(ReleaseEntry left, ReleaseEntry right) => Equals(left, right); - public static bool operator !=(ReleaseEntry left, ReleaseEntry right) - { - return !Equals(left, right); - } + /// + /// Returns true if the left and right instances are not equal. + /// + public static bool operator !=(ReleaseEntry left, ReleaseEntry right) => !Equals(left, right); } } \ No newline at end of file diff --git a/Katteker/Releases.cs b/Katteker/Releases.cs index 928c33e..668274b 100644 --- a/Katteker/Releases.cs +++ b/Katteker/Releases.cs @@ -6,6 +6,9 @@ using Semver; namespace Katteker { + /// + /// This class represents the release file which will published. + /// public class Releases : IEnumerable { private readonly string _filePath; @@ -17,6 +20,9 @@ namespace Katteker ReleaseEntries = new SortedList(); } + /// + /// Constructor with the path as paramter. + /// public Releases(string path) : this() { _filePath = Path.Combine(path, Constants.Release); @@ -24,6 +30,9 @@ namespace Katteker AddRange(File.ReadAllLines(_filePath)); } + /// + /// Constructor with the enumerable content. + /// public Releases(IEnumerable content) : this() { AddRange(content); @@ -38,6 +47,9 @@ namespace Katteker } } + /// + /// Write release file to disk. + /// public void WriteReleaseFile() { File.WriteAllLines(_filePath, ReleaseEntries.Select(x => x.Value.EntryAsString)); @@ -61,20 +73,23 @@ namespace Katteker { ReleaseEntries.Remove(version); } + ReleaseEntries.Add(version, entry); } + return entry; } + /// + /// Is true if the entry is the last entry. + /// + /// + /// public bool IsLatestEntry(ReleaseEntry entry) => entry.Equals(ReleaseEntries.LastOrDefault().Value); - public IEnumerator GetEnumerator() - { - return ReleaseEntries.Values.GetEnumerator(); - } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + /// + public IEnumerator GetEnumerator() => ReleaseEntries.Values.GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } } \ No newline at end of file diff --git a/Katteker/UpdateInfo.cs b/Katteker/UpdateInfo.cs index 1a51f94..52c599f 100644 --- a/Katteker/UpdateInfo.cs +++ b/Katteker/UpdateInfo.cs @@ -2,12 +2,24 @@ namespace Katteker { + /// + /// Info about the updates. + /// public class UpdateInfo { + /// + /// Currently installed version. + /// public ReleaseEntry CurrentlyInstalledVersion { get; } + /// + /// Releases to apply. + /// public List ReleasesToApply { get; } = new List(); + /// + /// Constructor + /// public UpdateInfo(string applicationName, Releases releases) { CurrentlyInstalledVersion = new ReleaseEntry(applicationName, VersionUtils.GetCurrentVersion());