本站首页    管理页面    写新日志    退出


«October 2026»
日一二三四五六
123
45678910
11121314151617
18192021222324
25262728293031


公告
暂无公告...

我的分类(专题)

日志更新

最新评论

留言板

链接


Blog信息
blog名称:
日志总数:11
评论数量:2
留言数量:0
访问次数:46579
建立时间:2008年8月31日




浅谈BlogEngine扩展机制的实现
文章收藏,  随笔,  电脑与网络

david_shar 发表于 2008/9/3 0:44:08

在Blogengine里,每一个扩展的Class都必须有Extension标记ExtensionAttribute是一个密封类,继承自System.Attribute,System.Attribute没有任何实现,只是一个标记而已。ExtensionAttribute类的代码:(完整代码可以从BlogEngine.NET.zip下载)   [AttributeUsage(AttributeTargets.Class)]  //指明该Attrubite只能应用于Class上      public sealed class ExtensionAttribute : System.Attribute      {        /// <summary>        /// Creates an instance of the attribute and assigns a description.        /// </summary>        public ExtensionAttribute(string description, string version, string author)        {          _Description = description;          _Version = version;          _Author = author;        }           private string _Description;        /// <summary>        /// Gets the description of the extension.        /// </summary>        public string Description        {          get { return _Description; }        }           private string _Version;           /// <summary>        /// Gets the version number of the extension        /// </summary>        public string Version        {          get { return _Version; }        }           private string _Author;           /// <summary>        /// Gets the author of the extension        /// </summary>        public string Author        {          get { return _Author; }        }         }   [AttributeUsage(AttributeTargets.Class)] //指明该Attrubite只能应用于Class上 public sealed class ExtensionAttribute : System.Attribute { /// <summary> /// Creates an instance of the attribute and assigns a description. /// </summary> public ExtensionAttribute(string description, string version, string author) { _Description = description; _Version = version; _Author = author; } private string _Description; /// <summary> /// Gets the description of the extension. /// </summary> public string Description { get { return _Description; } } private string _Version; /// <summary> /// Gets the version number of the extension /// </summary> public string Version { get { return _Version; } } private string _Author; /// <summary> /// Gets the author of the extension /// </summary> public string Author { get { return _Author; } } } 到这里很明了了,扩展类决定于它有没有打Extension标记,是否创建实例取决于该扩展有没有被启用.BlogEngine有很多地方是值得我们学习的.


阅读全文(1849) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.031 second(s), page refreshed 144924079 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号