PageRenderTime 37ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/BlogEngine/DotNetSlave.BusinessLogic/DataStore/SettingsBase.cs

#
C# | 69 lines | 28 code | 11 blank | 30 comment | 0 complexity | 602e3898987fd863c09b643a3dadc6ce MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. namespace BlogEngine.Core.DataStore
  2. {
  3. /// <summary>
  4. /// Base class for extension settings
  5. /// </summary>
  6. public abstract class SettingsBase
  7. {
  8. #region Constants and Fields
  9. /// <summary>
  10. /// Initializes a new instance of the <see cref="SettingsBase"/> class.
  11. /// </summary>
  12. protected SettingsBase()
  13. {
  14. this.SettingId = string.Empty;
  15. this.ExType = ExtensionType.Extension;
  16. }
  17. #endregion
  18. #region Properties
  19. /// <summary>
  20. /// Gets or sets the type of extension (extension, widget or theme)
  21. /// </summary>
  22. public ExtensionType ExType { get; set; }
  23. /// <summary>
  24. /// Gets or sets the Setting ID
  25. /// </summary>
  26. public string SettingId { get; set; }
  27. /// <summary>
  28. /// Gets or sets the Settings behavior
  29. /// </summary>
  30. public ISettingsBehavior SettingsBehavior { get; set; }
  31. #endregion
  32. #region Public Methods
  33. /// <summary>
  34. /// Get settings object from data storage
  35. /// </summary>
  36. /// <returns>
  37. /// Stream representing extension object
  38. /// </returns>
  39. public object GetSettings()
  40. {
  41. return this.SettingsBehavior.GetSettings(this.ExType, this.SettingId);
  42. }
  43. /// <summary>
  44. /// Saves setting object to data storage
  45. /// </summary>
  46. /// <param name="settings">
  47. /// Settings object
  48. /// </param>
  49. /// <returns>
  50. /// True if saved
  51. /// </returns>
  52. public bool SaveSettings(object settings)
  53. {
  54. return this.SettingsBehavior.SaveSettings(this.ExType, this.SettingId, settings);
  55. }
  56. #endregion
  57. }
  58. }