PageRenderTime 40ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/BlogEngine/DotNetSlave.BusinessLogic/CategoryDictionary.cs

#
C# | 82 lines | 46 code | 17 blank | 19 comment | 2 complexity | 31d7171aa39d0fec22ee5ad79a0f6a38 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. #region Using
  2. using System;
  3. using System.IO;
  4. using System.Collections.Generic;
  5. using System.Xml;
  6. using BlogEngine.Core.Providers;
  7. #endregion
  8. namespace BlogEngine.Core
  9. {
  10. /// <summary>
  11. /// A dictionary for all Post categories.
  12. /// </summary>
  13. [Serializable]
  14. public class CategoryDictionary : Dictionary<Guid, string>
  15. {
  16. internal static string _Folder = System.Web.HttpContext.Current.Server.MapPath(BlogSettings.Instance.StorageLocation);
  17. #region Properties
  18. private static CategoryDictionary _Instance = Load();
  19. /// <summary>
  20. /// Gets the singleton instance of the class.
  21. /// </summary>
  22. /// <value>An instance of CategoryDictionary.</value>
  23. public static CategoryDictionary Instance
  24. {
  25. get { return _Instance; }
  26. }
  27. #endregion
  28. #region Methods
  29. /// <summary>
  30. /// Adds a new category to the dictionary.
  31. /// </summary>
  32. /// <returns>The id of the new category.</returns>
  33. public Guid Add(string title)
  34. {
  35. Guid id = Guid.NewGuid();
  36. this.Add(id, title);
  37. return id;
  38. }
  39. /// <summary>
  40. /// Save the categories.
  41. /// </summary>
  42. public void Save()
  43. {
  44. //BlogService.SaveCategories(this);
  45. OnSaved();
  46. }
  47. private static CategoryDictionary Load()
  48. {
  49. // return BlogService.SelectCategories();
  50. return null;
  51. }
  52. #endregion
  53. /// <summary>
  54. /// Occurs when the class is Saved
  55. /// </summary>
  56. public static event EventHandler<EventArgs> Saved;
  57. private static void OnSaved()
  58. {
  59. if (Saved != null)
  60. {
  61. Saved(null, new EventArgs());
  62. }
  63. }
  64. }
  65. }