ConfigDescription.cs 874 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. namespace BepInEx.Configuration
  3. {
  4. //todo value range
  5. /// <summary>
  6. /// Metadata of a <see cref="ConfigEntry"/>.
  7. /// </summary>
  8. public class ConfigDescription
  9. {
  10. /// <summary>
  11. /// Create a new description.
  12. /// </summary>
  13. /// <param name="description">Text describing the function of the setting and any notes or warnings.</param>
  14. public ConfigDescription(string description)
  15. {
  16. Description = description ?? throw new ArgumentNullException(nameof(description));
  17. }
  18. /// <summary>
  19. /// Text describing the function of the setting and any notes or warnings.
  20. /// </summary>
  21. public string Description { get; }
  22. /// <summary>
  23. /// Convert the description object into a form suitable for writing into a config file.
  24. /// </summary>
  25. public string ToSerializedString()
  26. {
  27. return $"# {Description.Replace("\n", "\n# ")}";
  28. }
  29. }
  30. }