温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:LiveBlog v1.0测试版源码
当前文件:
LiveBlog/LiveBlog.Core/Page.cs,打开代码结构图
LiveBlog/LiveBlog.Core/Page.cs,打开代码结构图1Using#region Using 2
3
using System; 4
using System.Web; 5
using System.Collections.Generic; 6
using System.Text; 7
using System.IO; 8
using System.Xml; 9
using LiveBlog.Core.Providers; 10
11
#endregion 12
13
namespace LiveBlog.Core 14
...{ 15
/**//// <summary> 16
/// A page is much like a post, but is not part of the 17
/// blog chronology and is more static in nature. 18
/// <remarks> 19
/// Pages can be used for "About" pages or other static 20
/// information. 21
/// </remarks> 22
/// </summary> 23
public sealed class Page : BusinessBase<Page, Guid>, IPublishable 24
...{ 25
26
Constructor#region Constructor 27
28
/**//// <summary> 29
/// The contructor sets default values. 30
/// </summary> 31
public Page() 32
...{ 33
base.Id = Guid.NewGuid(); 34
DateCreated = DateTime.Now; 35
} 36
37
#endregion 38
39
Properties#region Properties 40
41
private string _Title; 42
/**//// <summary> 43
/// Gets or sets the Title or the object. 44
/// </summary> 45
public string Title 46
...{ 47
get ...{ return _Title; } 48
set 49
...{ 50
if (_Title != value) MarkChanged("Title"); 51
_Title = value; 52
} 53
} 54
55
private string _Content; 56
/**//// <summary> 57
/// Gets or sets the Description or the object. 58
/// </summary> 59
public string Content 60
...{ 61
get ...{ return _Content; } 62
set 63
...{ 64
if (_Content != value) MarkChanged("Content"); 65
_Content = value; 66
} 67
} 68
69
private string _Description; 70
/**//// <summary> 71
/// Gets or sets the Description or the object. 72
/// </summary> 73
public string Description 74
...{ 75
get ...{ return _Description; } 76
set 77
...{ 78
if (_Description != value) MarkChanged("Description"); 79
_Description = value; 80
} 81
} 82
83
private string _Keywords; 84
/**//// <summary> 85
/// Gets or sets the Keywords or the object. 86
/// </summary> 87
public string Keywords 88
...{ 89
get ...{ return _Keywords; } 90
set 91
...{ 92
if (_Keywords != value) MarkChanged("Keywords"); 93
_Keywords = value; 94
} 95
} 96
97
private Guid _Parent; 98
/**//// <summary> 99
/// Gets or sets the parent of the Page. It is used to construct the 100
/// hierachy of the pages. 101
/// </summary> 102
public Guid Parent 103
...{ 104
get ...{ return _Parent; } 105
set 106
...{ 107
if (_Parent != value) MarkChanged("Parent"); 108
_Parent = value; 109
} 110
} 111
112
private string _Slug; 113
/**//// <summary> 114
/// Gets or sets the Slug of the Page. 115
/// A Slug is the relative URL used by the pages. 116
/// </summary> 117
public string Slug 118
...{ 119
get 120
...{ 121
if (string.IsNullOrEmpty(_Slug)) 122
return Utils.RemoveIllegalCharacters(Title); 123
124
return _Slug; 125
} 126
set ...{ _Slug = value; } 127
} 128
129
private bool _IsPublished; 130
/**//// <summary> 131
/// Gets or sets whether or not this page should be published. 132
/// </summary> 133
public bool IsPublished 134
...{ 135
get ...{ return _IsPublished; } 136
set 137
...{ 138
if (_IsPublished != value) MarkChanged("IsPublished"); 139
_IsPublished = value; 140
} 141
} 142
143
/**//// <summary> 144
/// Gets whether or not this page should be shown 145
/// </summary> 146
/// <value></value> 147
public bool IsVisible 148
...{ 149
get ...{ return IsPublished; } 150
} 151
152
private bool _IsFrontPage; 153
/**//// <summary> 154
/// Gets or sets whether or not this page should be displayed on the front page. 155
/// </summary> 156
public bool IsFrontPage 157
...{ 158
get ...{ return _IsFrontPage; } 159
set 160
...{ 161
if (_IsFrontPage != value) MarkChanged("IsFrontPage"); 162
_IsFrontPage = value; 163
} 164
} 165
166
private bool _ShowInList; 167
/**//// <summary> 168
/// Gets or sets whether or not this page should be in the sitemap list. 169
/// </summary> 170
public bool ShowInList 171
...{ 172
get ...{ return _ShowInList; } 173
set 174
...{ 175
if (_ShowInList != value) MarkChanged("ShowInList"); 176
_ShowInList = value; 177
} 178
} 179
180
/**//// <summary> 181
/// A relative-to-the-site-root path to the post. 182
/// Only for in-site use. 183
/// </summary> 184
public string RelativeLink 185
...{ 186
get 187
...{ 188
string slug = Utils.RemoveIllegalCharacters(Slug) + BlogSettings.Instance.FileExtension; 189
return Utils.RelativeWebRoot + "page/" + slug; 190
} 191
} 192
193
/**//// <summary> 194
/// The absolute URI to the path. 195
/// </summary> 196
public Uri AbsoluteLink 197
...{ 198
get ...{ return Utils.ConvertToAbsolute(RelativeLink); } 199
} 200
201
private static object _SyncRoot = new object(); 202
private static List<Page> _Pages; 203
/**//// <summary> 204
/// Gets an unsorted list of all pages. 205
/// </summary> 206
public static List<Page> Pages 207
...{ 208
get 209
...{ 210
if (_Pages == null) 211
...{ 212
lock (_SyncRoot) 213
...{ 214
if (_Pages == null) 215
...{ 216
_Pages = BlogService.FillPages(); 217
_Pages.Sort(delegate(Page p1, Page p2) ...{ return String.Compare(p1.Title, p2.Title); }); 218
} 219
} 220
} 221
222
return _Pages; 223
} 224
} 225
226
/**//// <summary> 227
/// Returns a page based on the specified id. 228
/// </summary> 229
public static Page GetPage(Guid id) 230
...{ 231
foreach (Page page in Pages) 232
...{ 233
if (page.Id == id) 234
return page; 235
} 236
237
return null; 238
} 239
240
/**//// <summary> 241
/// Returns the front page if any is available. 242
/// </summary> 243
public static Page GetFrontPage() 244
...{ 245
foreach (Page page in Pages) 246
...{ 247
if (page.IsFrontPage) 248
return page; 249
} 250
251
return null; 252
} 253
254




