PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/widgets/Twitter/edit.ascx.cs

#
C# | 75 lines | 41 code | 13 blank | 21 comment | 1 complexity | 85d8dfbed38115627eebf5cfb6a675fb MD5 | raw file
 1// --------------------------------------------------------------------------------------------------------------------
 2// <summary>
 3//   The edit.
 4// </summary>
 5// --------------------------------------------------------------------------------------------------------------------
 6
 7namespace Widgets.Twitter
 8{
 9    using System;
10    using System.Web;
11
12    using App_Code.Controls;
13    using BlogEngine.Core;
14
15    /// <summary>
16    /// The edit.
17    /// </summary>
18    public partial class Edit : WidgetEditBase
19    {
20        #region Constants and Fields
21
22        /// <summary>
23        /// The twitter settings cache key.
24        /// </summary>
25        private const string TwitterSettingsCacheKey = "twitter-settings"; // same key used in widget.ascx.cs.
26
27        #endregion
28
29        #region Public Methods
30
31        /// <summary>
32        /// Saves this the basic widget settings such as the Title.
33        /// </summary>
34        public override void Save()
35        {
36            var settings = this.GetSettings();
37            settings["feedurl"] = this.txtUrl.Text;
38            settings["accounturl"] = this.txtAccountUrl.Text;
39            settings["maxitems"] = this.txtTwits.Text;
40            settings["pollinginterval"] = this.txtPolling.Text;
41            settings["followmetext"] = this.txtFollowMe.Text;
42            this.SaveSettings(settings);
43
44            // Don't need to clear Feed out of cache because when the Settings are cleared,
45            // the last modified date (i.e. TwitterSettings.LastModified) will reset to
46            // DateTime.MinValue and Twitter will be re-queried.
47            Blog.CurrentInstance.Cache.Remove(TwitterSettingsCacheKey);
48        }
49
50        #endregion
51
52        #region Methods
53
54        /// <summary>
55        /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
56        /// </summary>
57        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
58        protected override void OnInit(EventArgs e)
59        {
60            var settings = this.GetSettings();
61            if (settings.ContainsKey("feedurl"))
62            {
63                this.txtUrl.Text = settings["feedurl"];
64                this.txtAccountUrl.Text = settings["accounturl"];
65                this.txtTwits.Text = settings["maxitems"];
66                this.txtPolling.Text = settings["pollinginterval"];
67                this.txtFollowMe.Text = settings["followmetext"];
68            }
69
70            base.OnInit(e);
71        }
72
73        #endregion
74    }
75}