概述:
这个类是Weblog的页面的模版类
类图如下:
1. CurrentWeblog属性
private Weblog weblog = null;
/// <summary>
/// Returns the CurrentWeb and calls Authorize
/// </summary>
public virtual Weblog CurrentWeblog
{
get
{
if(weblog == null)
{
weblog = Weblogs.GetWeblog(CSContext.Current.ApplicationKey,true);
if(!this.CurrentUser.IsBlogAdministrator)
Authorize(weblog);
}
return weblog;
}
}
/// <summary>
/// Returns the CurrentWeb and calls Authorize
/// </summary>
public virtual Weblog CurrentWeblog
{
get
{
if(weblog == null)
{
weblog = Weblogs.GetWeblog(CSContext.Current.ApplicationKey,true);
if(!this.CurrentUser.IsBlogAdministrator)
Authorize(weblog);
}
return weblog;
}
}
这个属性是公有的,作用是:Returns the CurrentWeb and calls Authorize。
具体步骤如下:
(1) 用到了Weblogs.GetWeblog方法和CSContext.Current.ApplicationKey属性,用来得到当前的Weblog对象,
(2) 如果当前用户不是管理员,就调用本类的Authorize方法,判断用户是否具有Permission.View权限。
2.Authorize(Weblog w)方法
/// <summary>
/// By default, checks to see if a blog exists and if the user has read access
/// </summary>
/// <param name="w"></param>
protected virtual void Authorize(Weblog w)
{
if(w == null)
PermissionBase.RedirectOrExcpetion(CSExceptionType.SectionNotFound,string.Format("Weblog {0} could not be found",CSContext.Current.ApplicationKey));
Permissions.AccessCheck(w,Permission.View,this.CurrentUser);
}
/// By default, checks to see if a blog exists and if the user has read access
/// </summary>
/// <param name="w"></param>
protected virtual void Authorize(Weblog w)
{
if(w == null)
PermissionBase.RedirectOrExcpetion(CSExceptionType.SectionNotFound,string.Format("Weblog {0} could not be found",CSContext.Current.ApplicationKey));
Permissions.AccessCheck(w,Permission.View,this.CurrentUser);
}
该方法是protected方法,只能被它的子类调用。作用是:By default, checks to see if a blog exists and if the user has read access.
具体步骤是:
(1) 判断传入的Weblog对象是否存在,如果不存在就抛出异常。
(2) 检查当前用户是否具有Permission.View权限
由此:可得该类的类图已经关联类图如下:
(还有一个枚举类型没有在图中表现出来,具体原因见如何让VISIO显示枚举类型时只显示名称?)





}
浙公网安备 33010602011771号