diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-02-18 15:39:49 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-02-18 15:39:49 -0500 |
commit | a2190df08cc3f1b4a8dcb394056d65921d10702e (patch) | |
tree | 3feb0e4726ec0df49e456ca286a6e565c57ec561 /src/SMAPI/Framework/Content/AssetInfo.cs | |
parent | 065859408f4e88ea1154b1fc76f7df5288e51b53 (diff) | |
download | SMAPI-a2190df08cc3f1b4a8dcb394056d65921d10702e.tar.gz SMAPI-a2190df08cc3f1b4a8dcb394056d65921d10702e.tar.bz2 SMAPI-a2190df08cc3f1b4a8dcb394056d65921d10702e.zip |
add AssetName to encapsulate asset name handling (#766)
Diffstat (limited to 'src/SMAPI/Framework/Content/AssetInfo.cs')
-rw-r--r-- | src/SMAPI/Framework/Content/AssetInfo.cs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/SMAPI/Framework/Content/AssetInfo.cs b/src/SMAPI/Framework/Content/AssetInfo.cs index d8106439..6a5b4f31 100644 --- a/src/SMAPI/Framework/Content/AssetInfo.cs +++ b/src/SMAPI/Framework/Content/AssetInfo.cs @@ -20,7 +20,11 @@ namespace StardewModdingAPI.Framework.Content public string Locale { get; } /// <inheritdoc /> - public string AssetName { get; } + public IAssetName Name { get; } + + /// <inheritdoc /> + [Obsolete($"Use {nameof(Name)} instead.")] + public string AssetName => this.Name.Name; /// <inheritdoc /> public Type DataType { get; } @@ -31,22 +35,22 @@ namespace StardewModdingAPI.Framework.Content *********/ /// <summary>Construct an instance.</summary> /// <param name="locale">The content's locale code, if the content is localized.</param> - /// <param name="assetName">The normalized asset name being read.</param> + /// <param name="assetName">The asset name being read.</param> /// <param name="type">The content type being read.</param> /// <param name="getNormalizedPath">Normalizes an asset key to match the cache key.</param> - public AssetInfo(string locale, string assetName, Type type, Func<string, string> getNormalizedPath) + public AssetInfo(string locale, IAssetName assetName, Type type, Func<string, string> getNormalizedPath) { this.Locale = locale; - this.AssetName = assetName; + this.Name = assetName; this.DataType = type; this.GetNormalizedPath = getNormalizedPath; } /// <inheritdoc /> + [Obsolete($"Use {nameof(Name)}.{nameof(IAssetName.IsEquivalentTo)} instead.")] public bool AssetNameEquals(string path) { - path = this.GetNormalizedPath(path); - return this.AssetName.Equals(path, StringComparison.OrdinalIgnoreCase); + return this.Name.IsEquivalentTo(path); } |