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

/BlogEngine/DotNetSlave.BusinessLogic/CategoryDictionary.cs

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