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