Changed ToDescriptionString to return toString if no description is present

This commit is contained in:
erri120 2019-11-18 18:06:17 +01:00
parent 2fde106b92
commit bb2661f968
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
3 changed files with 5 additions and 17 deletions

View File

@ -23,8 +23,8 @@ namespace Wabbajack.Common
throw new ArgumentException("T must be an Enum");
}
DescriptionAttribute[] attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);
return attributes.Length > 0 ? attributes[0].Description : string.Empty;
var attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);
return attributes.Length > 0 ? attributes[0].Description : val.ToString();
}
}
}

View File

@ -32,8 +32,7 @@ namespace Wabbajack.Lib.ModListRegistry
[JsonProperty("game")]
public Game Game { get; set; }
[JsonIgnore]
public string GameName { get; set; }
[JsonIgnore] public string GameName => this.Game.ToDescriptionString();
[JsonProperty("official")]
public bool Official { get; set; }
@ -80,15 +79,8 @@ namespace Wabbajack.Lib.ModListRegistry
{
var client = new HttpClient();
Utils.Log("Loading ModLists from Github");
var result = client.GetStringSync(Consts.ModlistMetadataURL);
var list = result.FromJSONString<List<ModlistMetadata>>();
list.Do(m =>
{
m.GameName = m.Game.ToDescriptionString();
if (string.IsNullOrWhiteSpace(m.GameName))
m.GameName = m.Game.ToString();
});
return list;
var result = client.GetStringSync(Consts.ModlistMetadataURL);
return result.FromJSONString<List<ModlistMetadata>>();
}
public bool NeedsDownload(string modlistPath)

View File

@ -16,10 +16,6 @@ namespace Wabbajack
{
this.Game = game;
this.DisplayName = game.ToDescriptionString();
if (string.IsNullOrWhiteSpace(this.DisplayName))
{
this.DisplayName = game.ToString();
}
}
}
}