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