PageRenderTime 14ms CodeModel.GetById 8ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
C# | 69 lines | 28 code | 11 blank | 30 comment | 0 complexity | 602e3898987fd863c09b643a3dadc6ce MD5 | raw file
 1namespace 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
10        /// <summary>
11        /// Initializes a new instance of the <see cref="SettingsBase"/> class.
12        /// </summary>
13        protected SettingsBase()
14        {
15            this.SettingId = string.Empty;
16            this.ExType = ExtensionType.Extension;
17        }
18
19        #endregion
20
21        #region Properties
22
23        /// <summary>
24        ///     Gets or sets the type of extension (extension, widget or theme)
25        /// </summary>
26        public ExtensionType ExType { get; set; }
27
28        /// <summary>
29        ///     Gets or sets the Setting ID
30        /// </summary>
31        public string SettingId { get; set; }
32
33        /// <summary>
34        ///     Gets or sets the Settings behavior
35        /// </summary>
36        public ISettingsBehavior SettingsBehavior { get; set; }
37
38        #endregion
39
40        #region Public Methods
41
42        /// <summary>
43        /// Get settings object from data storage
44        /// </summary>
45        /// <returns>
46        /// Stream representing extension object
47        /// </returns>
48        public object GetSettings()
49        {
50            return this.SettingsBehavior.GetSettings(this.ExType, this.SettingId);
51        }
52
53        /// <summary>
54        /// Saves setting object to data storage
55        /// </summary>
56        /// <param name="settings">
57        /// Settings object
58        /// </param>
59        /// <returns>
60        /// True if saved
61        /// </returns>
62        public bool SaveSettings(object settings)
63        {
64            return this.SettingsBehavior.SaveSettings(this.ExType, this.SettingId, settings);
65        }
66
67        #endregion
68    }
69}