惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
Microsoft Azure Blog
Microsoft Azure Blog
H
Help Net Security
N
News and Events Feed by Topic
Recent Announcements
Recent Announcements
D
Docker
M
MIT News - Artificial intelligence
L
LangChain Blog
I
InfoQ
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
博客园_首页
MongoDB | Blog
MongoDB | Blog
美团技术团队
S
Schneier on Security
G
GRAHAM CLULEY
月光博客
月光博客
有赞技术团队
有赞技术团队
Vercel News
Vercel News
Scott Helme
Scott Helme
P
Privacy International News Feed
Last Week in AI
Last Week in AI
Recorded Future
Recorded Future
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
Attack and Defense Labs
Attack and Defense Labs
Google Online Security Blog
Google Online Security Blog
Simon Willison's Weblog
Simon Willison's Weblog
量子位
S
Security @ Cisco Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
V
Visual Studio Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
NISL@THU
NISL@THU
N
Netflix TechBlog - Medium
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Spread Privacy
Spread Privacy
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
罗磊的独立博客
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Threatpost
L
Lohrmann on Cybersecurity
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Security Affairs
Cloudbric
Cloudbric
爱范儿
爱范儿
H
Heimdal Security Blog
PCI Perspectives
PCI Perspectives

博客园 - TG.Yang's IT Space

提高工作效率之数据库工具 Unity(3) Unity(2)生命周期 Unity(1)控制反转 (转)常用的js代码 转:Oracle数据导入导出imp/exp命令 AspNet2.0页面生命周期(转) offsetLeft,Left,clientLeft的区别 发邮件窗体【支持编辑邮件模板,使用wse多线程上传附件及发邮件(带附件)】以及在服务器端自动发邮件 (mark)Oracle Update Statements Oracle 8i and 9i分析函数(转) row_number()over函数的使用(转) Community Server 资源 13个在线web2.0风格生成器 jQuery1.2选择器(转) 键盘输入工作原理 ORACLE 中ROWNUM用法总结 SQLServer和Oracle的常用函数对比 如何在Oracle里实现自增
BlogEngine.net学习(一)——实体类
TG.Yang's IT Space · 2008-06-13 · via 博客园 - TG.Yang's IT Space

    在BlogEngine.net中处理的和业务相关的实体有Post(文章),Page(页面),Category(目录)。其中的类关系图如下
所有需要发布的实体都需要实现IPublishiable接口。其中业务实体都可对应多个目录,则在IPublishiable接口中有  StateList<Category> Categories { get;}字段。StateList可以检测是否已经修改过。
其中实现如下:

 1     /// <summary>
 2     /// A generic collection with the ability to 
 3     /// check if it has been changed.
 4     /// </summary>
 5     [System.Serializable]
 6     public class StateList<T> : System.Collections.Generic.List<T>
 7     {
 8 
 9         #region Base overrides
10         /// <summary>
11         /// Serves as a hash function for a particular type. <see cref="M:System.Object.GetHashCode"></see> is suitable for use in hashing algorithms and data structures like a hash table.
12         /// </summary>
13         /// <returns>
14         /// A hash code for the current <see cref="T:System.Object"></see>.
15         /// </returns>
16         public override int GetHashCode()
17         {
18             string hash = string.Empty;
19             foreach (T item in this)
20             {
21                 hash += item.GetHashCode().ToString();
22             }
23 
24             return hash.GetHashCode();
25         }
26 
27         /// <summary>
28         /// Determines whether the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>.
29         /// </summary>
30         /// <param name="obj">The <see cref="T:System.Object"></see> to compare with the current <see cref="T:System.Object"></see>.</param>
31         /// <returns>
32         /// true if the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>; otherwise, false.
33         /// </returns>
34         public override bool Equals(object obj)
35         {
36             if (obj == null)
37             {
38                 return false;
39             }
40 
41             if (obj.GetType() == this.GetType())
42             {
43                 return obj.GetHashCode() == this.GetHashCode();
44             }
45 
46             return false;
47         }
48 
49         #endregion
50 
51         private int _HasCode = 0;
52 
53         /// <summary>
54         /// Gets if this object's data has been changed.
55         /// </summary>
56         /// <returns>A value indicating if this object's data has been changed.</returns>
57         public virtual bool IsChanged
58         {
59             get
60             {
61                 return this.GetHashCode() != _HasCode;
62             }
63         }
64 
65         /// <summary>
66         /// Marks the object as being clean, 
67         /// which means not changed.
68         /// </summary>
69         public virtual void MarkOld()
70         {
71             _HasCode = this.GetHashCode();
72             base.TrimExcess();
73         }
74     }
75