IConfigurationService.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using GreenTree.Nachtragsmanagement.Core.Configuration;
  7. using GreenTree.Nachtragsmanagement.Core.Domain.Config;
  8. namespace GreenTree.Nachtragsmanagement.Services.Configuration
  9. {
  10. public interface IConfigurationService
  11. {
  12. /// <summary>
  13. /// Reads the current configuration from the global config
  14. /// </summary>
  15. AppendixConfigurationSection GetCurrentConfiguration();
  16. #region ConfigItem
  17. /// <summary>
  18. /// Gets all configItems
  19. /// </summary>
  20. IList<ConfigItem> GetAllConfigItems();
  21. /// <summary>
  22. /// Gets a configItem by specified Id
  23. /// </summary>
  24. /// <param name="id">ConfigItem identifier.</param>
  25. ConfigItem GetConfigItemById(int id);
  26. /// <summary>
  27. /// Gets a configItem by specified name
  28. /// </summary>
  29. /// <param name="name">ConfigItem name.</param>
  30. ConfigItem GetConfigItemByName(string name);
  31. /// <summary>
  32. /// Gets all configItems to the specified ids
  33. /// </summary>
  34. IList<ConfigItem> GetConfigItemsByIds(int[] ids);
  35. /// <summary>
  36. /// Insert a configItem
  37. /// </summary>
  38. /// <param name="configItem">ConfigItem.</param>
  39. void InsertConfigItem(ConfigItem configItem);
  40. /// <summary>
  41. /// Update a configItem
  42. /// </summary>
  43. /// <param name="configItem">ConfigItem.</param>
  44. void UpdateConfigItem(ConfigItem configItem);
  45. /// <summary>
  46. /// Delete a configItem
  47. /// </summary>
  48. /// <param name="configItem">ConfigItem.</param>
  49. void DeleteConfigItem(ConfigItem configItem);
  50. #endregion
  51. #region Casting
  52. /// <summary>
  53. /// Trys to convert the config items value type and returns its actual value, otherwise NULL
  54. /// </summary>
  55. /// <typeparam name="T">The actual type.</typeparam>
  56. /// <param name="configItem">ConfigItem.</param>
  57. /// <param name="defaultValue">Value, when conversion fails.</param>
  58. T TryGetConfigItemValue<T>(ConfigItem configItem, T defaultValue);
  59. /// <summary>
  60. /// Trys to convert the config items value type and returns its actual value, otherwise NULL
  61. /// </summary>
  62. /// <typeparam name="T">The actual type.</typeparam>
  63. /// <param name="configItemName">ConfigItem name.</param>
  64. /// <param name="defaultValue">Value, when conversion fails.</param>
  65. T TryGetConfigItemValue<T>(string configItemName, T defaultValue);
  66. #endregion
  67. }
  68. }