-
Notifications
You must be signed in to change notification settings - Fork 0
/
Article.cs
67 lines (60 loc) · 2.34 KB
/
Article.cs
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
public class Article : IBlogContent
{
public string Title { get; }
public string Filename { get; }
public List<string> Tags { get; }
public string Description { get; }
public string CreatedAt { get; }
public string UpdatedAt { get; }
public bool IsTop { get; }
public bool IsHidden { get; }
public bool IsCommentEnabled { get; }
public string BlogPath { get; }
public string ArticlePath { get; }
public int IndexValue { get; }
public void Edit()
{
new System.Diagnostics.Process
{
StartInfo = new System.Diagnostics.ProcessStartInfo(this.ArticlePath)
{
UseShellExecute = true
}
}.Start();
}
public void Delete(){
BlogIndexJson BlogIndexJsonObj = new BlogIndexJson(this.BlogPath);
BlogIndexJsonObj.RemoveArticleInIndexJson(this.IndexValue);
System.IO.File.Delete(this.ArticlePath);
}
public List<string> GetListOfArticleProperties(){
var Properties = typeof(Article).GetProperties();
List<string> ResultList = new List<string> {};
foreach(var Property in Properties){
// 去除不建议被修改的值
if ((string) Property.Name != "BlogPath" && (string) Property.Name != "ArticlePath" && (string) Property.Name != "IndexValue"){
ResultList.Add(Property.Name);
}
}
return ResultList;
}
public void SetArticleProperty<TValue>(string key, TValue value){
BlogIndexJson BlogIndexJsonObj = new BlogIndexJson(this.BlogPath);
BlogIndexJsonObj.SetAttributeOfArticleInIndexJson<TValue>(this.IndexValue, key, value);
}
public Article(string Title, string Filename, List<string> Tags, string Description, string CreatedAt, string UpdatedAt, bool IsTop, bool IsHidden, bool IsCommentEnabled, string BlogPath, int IndexValue)
{
this.Title = Title;
this.Filename = Filename;
this.Tags = Tags;
this.Description = Description;
this.CreatedAt = CreatedAt;
this.UpdatedAt = UpdatedAt;
this.IsTop = IsTop;
this.IsHidden = IsHidden;
this.IsCommentEnabled = IsCommentEnabled;
this.BlogPath = BlogPath;
this.ArticlePath = Path.Join(this.BlogPath, "data", "articles", this.Filename);
this.IndexValue = IndexValue;
}
}