diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-09-13 17:22:45 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-09-13 17:22:45 -0400 |
commit | 125bcbee56bf40cf82abc7fdb502f8cbc18546cf (patch) | |
tree | 788997dd4683867b6e32e307c17c855bd7209d98 /src/StardewModdingAPI.Toolkit/Framework/UpdateData | |
parent | 56726073ba65a018312bcd9db7072381073de315 (diff) | |
download | SMAPI-125bcbee56bf40cf82abc7fdb502f8cbc18546cf.tar.gz SMAPI-125bcbee56bf40cf82abc7fdb502f8cbc18546cf.tar.bz2 SMAPI-125bcbee56bf40cf82abc7fdb502f8cbc18546cf.zip |
migrate to new project file format
Diffstat (limited to 'src/StardewModdingAPI.Toolkit/Framework/UpdateData')
-rw-r--r-- | src/StardewModdingAPI.Toolkit/Framework/UpdateData/ModRepositoryKey.cs | 21 | ||||
-rw-r--r-- | src/StardewModdingAPI.Toolkit/Framework/UpdateData/UpdateKey.cs | 73 |
2 files changed, 0 insertions, 94 deletions
diff --git a/src/StardewModdingAPI.Toolkit/Framework/UpdateData/ModRepositoryKey.cs b/src/StardewModdingAPI.Toolkit/Framework/UpdateData/ModRepositoryKey.cs deleted file mode 100644 index f6c402d5..00000000 --- a/src/StardewModdingAPI.Toolkit/Framework/UpdateData/ModRepositoryKey.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace StardewModdingAPI.Toolkit.Framework.UpdateData -{ - /// <summary>A mod repository which SMAPI can check for updates.</summary> - public enum ModRepositoryKey - { - /// <summary>An unknown or invalid mod repository.</summary> - Unknown, - - /// <summary>The Chucklefish mod repository.</summary> - Chucklefish, - - /// <summary>A GitHub project containing releases.</summary> - GitHub, - - /// <summary>The ModDrop mod repository.</summary> - ModDrop, - - /// <summary>The Nexus Mods mod repository.</summary> - Nexus - } -} diff --git a/src/StardewModdingAPI.Toolkit/Framework/UpdateData/UpdateKey.cs b/src/StardewModdingAPI.Toolkit/Framework/UpdateData/UpdateKey.cs deleted file mode 100644 index 865ebcf7..00000000 --- a/src/StardewModdingAPI.Toolkit/Framework/UpdateData/UpdateKey.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; - -namespace StardewModdingAPI.Toolkit.Framework.UpdateData -{ - /// <summary>A namespaced mod ID which uniquely identifies a mod within a mod repository.</summary> - public class UpdateKey - { - /********* - ** Accessors - *********/ - /// <summary>The raw update key text.</summary> - public string RawText { get; } - - /// <summary>The mod repository containing the mod.</summary> - public ModRepositoryKey Repository { get; } - - /// <summary>The mod ID within the repository.</summary> - public string ID { get; } - - /// <summary>Whether the update key seems to be valid.</summary> - public bool LooksValid { get; } - - - /********* - ** Public methods - *********/ - /// <summary>Construct an instance.</summary> - /// <param name="rawText">The raw update key text.</param> - /// <param name="repository">The mod repository containing the mod.</param> - /// <param name="id">The mod ID within the repository.</param> - public UpdateKey(string rawText, ModRepositoryKey repository, string id) - { - this.RawText = rawText; - this.Repository = repository; - this.ID = id; - this.LooksValid = - repository != ModRepositoryKey.Unknown - && !string.IsNullOrWhiteSpace(id); - } - - /// <summary>Parse a raw update key.</summary> - /// <param name="raw">The raw update key to parse.</param> - public static UpdateKey Parse(string raw) - { - // split parts - string[] parts = raw?.Split(':'); - if (parts == null || parts.Length != 2) - return new UpdateKey(raw, ModRepositoryKey.Unknown, null); - - // extract parts - string repositoryKey = parts[0].Trim(); - string id = parts[1].Trim(); - if (string.IsNullOrWhiteSpace(id)) - id = null; - - // parse - if (!Enum.TryParse(repositoryKey, true, out ModRepositoryKey repository)) - return new UpdateKey(raw, ModRepositoryKey.Unknown, id); - if (id == null) - return new UpdateKey(raw, repository, null); - - return new UpdateKey(raw, repository, id); - } - - /// <summary>Get a string that represents the current object.</summary> - public override string ToString() - { - return this.LooksValid - ? $"{this.Repository}:{this.ID}" - : this.RawText; - } - } -} |