BlogEngine.net---BusinessBase
最近总想学点什么来提升自己,由此我开始学习BlogEngine,嘿嘿。
http://www.cnblogs.com/Thriving-Country/archive/2008/11/04/1326334.html 这是一个大大写的相关文章,就是版本老了点,
但是原理相通么,呵呵。我下了BlogEngine.net 2.5版本的。
好了,开始旅程。
打开工程,首先运行一遍,然后我就想从哪开始看,头大啊,好在有别人写的东西做参考,省了很多时间。
在工程里有一个叫做BusinessBase的基类,其他所有的功能都是基于这个类进行展开的,不废话了,这些别人都已说过,我的重点是分析代码。

1 public abstract class BusinessBase<T, TKey> : IDataErrorInfo, INotifyPropertyChanged, INotifyPropertyChanging, IChangeTracking, IDisposable
2 where T : BusinessBase<T, TKey>, new()
这是一个泛型类,实现了好多接口啊!IDataErrorInfo, INotifyPropertyChanged, INotifyPropertyChanging, IChangeTracking, IDisposable
除了IDisposable,其他都是System.dll里的,看下这些接口都是些什么。

1 // Summary:
2 // Provides the functionality to offer custom error information that a user
3 // interface can bind to.
4 public interface IDataErrorInfo
5 {
6 // Summary:
7 // Gets an error message indicating what is wrong with this object.
8 //
9 // Returns:
10 // An error message indicating what is wrong with this object. The default is
11 // an empty string ("").
12 string Error { get; }
13
14 // Summary:
15 // Gets the error message for the property with the given name.
16 //
17 // Parameters:
18 // columnName:
19 // The name of the property whose error message to get.
20 //
21 // Returns:
22 // The error message for the property. The default is an empty string ("").
23 string this[string columnName] { get; }
24 }

1 // Summary:
2 // Notifies clients that a property value has changed.
3 public interface INotifyPropertyChanged
4 {
5 // Summary:
6 // Occurs when a property value changes.
7 event PropertyChangedEventHandler PropertyChanged;
8 }

1 // Summary:
2 // Notifies clients that a property value is changing.
3 public interface INotifyPropertyChanging
4 {
5 // Summary:
6 // Occurs when a property value is changing.
7 event PropertyChangingEventHandler PropertyChanging;
8 }

1 // Summary:
2 // Defines the mechanism for querying the object for changes and resetting of
3 // the changed status.
4 public interface IChangeTracking
5 {
6 // Summary:
7 // Gets the object's changed status.
8 //
9 // Returns:
10 // true if the object’s content has changed since the last call to System.ComponentModel.IChangeTracking.AcceptChanges();
11 // otherwise, false.
12 bool IsChanged { get; }
13
14 // Summary:
15 // Resets the object’s state to unchanged by accepting the modifications.
16 void AcceptChanges();
17 }
看了下,原来也没多少,什么错误消息,属性改变事件相关的东西。
回到BusinessBase 这个类,才发现包含了大量的公共属性,方法,我是不是说了句废话.....
看下面的类关系图
好家伙,下面有7个儿子呢。看看这些儿子们是分别干什么的吧。
AuthorProfile 用户注册信息
Blog 代表一个博客实例
BlogRollItem 博客友情链接
Page 静态页面信息
Referrer 反向链接信息
Post 提交的一篇文章信息
Category 文章种类
至于细节方面实在太多,再说再说。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?