IDictionaryBasedConfig.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. namespace Abp.Configuration
  3. {
  4. /// <summary>
  5. /// Defines interface to use a dictionary to make configurations.
  6. /// </summary>
  7. public interface IDictionaryBasedConfig
  8. {
  9. /// <summary>
  10. /// Used to set a string named configuration.
  11. /// If there is already a configuration with same <paramref name="name"/>, it's overwritten.
  12. /// </summary>
  13. /// <param name="name">Unique name of the configuration</param>
  14. /// <param name="value">Value of the configuration</param>
  15. /// <returns>Returns the passed <paramref name="value"/></returns>
  16. void Set<T>(string name, T value);
  17. /// <summary>
  18. /// Gets a configuration object with given name.
  19. /// </summary>
  20. /// <param name="name">Unique name of the configuration</param>
  21. /// <returns>Value of the configuration or null if not found</returns>
  22. object Get(string name);
  23. /// <summary>
  24. /// Gets a configuration object with given name.
  25. /// </summary>
  26. /// <typeparam name="T">Type of the object</typeparam>
  27. /// <param name="name">Unique name of the configuration</param>
  28. /// <returns>Value of the configuration or null if not found</returns>
  29. T Get<T>(string name);
  30. /// <summary>
  31. /// Gets a configuration object with given name.
  32. /// </summary>
  33. /// <param name="name">Unique name of the configuration</param>
  34. /// <param name="defaultValue">Default value of the object if can not found given configuration</param>
  35. /// <returns>Value of the configuration or null if not found</returns>
  36. object Get(string name, object defaultValue);
  37. /// <summary>
  38. /// Gets a configuration object with given name.
  39. /// </summary>
  40. /// <typeparam name="T">Type of the object</typeparam>
  41. /// <param name="name">Unique name of the configuration</param>
  42. /// <param name="defaultValue">Default value of the object if can not found given configuration</param>
  43. /// <returns>Value of the configuration or null if not found</returns>
  44. T Get<T>(string name, T defaultValue);
  45. /// <summary>
  46. /// Gets a configuration object with given name.
  47. /// </summary>
  48. /// <typeparam name="T">Type of the object</typeparam>
  49. /// <param name="name">Unique name of the configuration</param>
  50. /// <param name="creator">The function that will be called to create if given configuration is not found</param>
  51. /// <returns>Value of the configuration or null if not found</returns>
  52. T GetOrCreate<T>(string name, Func<T> creator);
  53. }
  54. }