/// <summary>Loads <see cref="Content"/> from the provided json.</summary> public void LoadContent(string json) { var cont = JsonConvert.DeserializeObject <BotContent>(json); var missingFields = typeof(BotContent).GetFields().Where(x => x.GetValue(cont) is null).ToList(); if (missingFields.Count > 0) { throw new InvalidOperationException( $"The contents file is missing a value for: {missingFields.Select(x => x.Name).JoinString(", ")}"); } Content = cont; }
/// <summary>Reloads <see cref="Content"/> from the provided json.</summary> public void LoadContent(string json) { var cont = JsonConvert.DeserializeObject <BotContent>(json); var missingFields = typeof(BotContent).GetFields().Where(x => x.GetValue(cont) == null).ToList(); if (missingFields.Count > 0) { throw new InvalidOperationException( $"The contents file is missing a value for: {missingFields.Select(x => x.Name).JoinString(", ")}"); } for (int i = 0; i < cont.aboutFields.Length; i++) { (string name, string desc) = cont.aboutFields[i]; cont.aboutFields[i] = (name, desc.Replace("{version}", cont.version)); } Content = cont; }