📄 directorywriter.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using CommunityServer.Components;
namespace CommunityServer.Controls
{
/// <summary>
/// Summary description for DirectoryWriter.
/// </summary>
public class DirectoryWriter : Label
{
public DirectoryWriter()
{
}
protected DirectoryAccess directoryAccess = DirectoryAccess.Success;
protected bool HasAccess
{
get
{
object obj = ViewState["HasAccess"];
return (obj == null) ? false : (bool)obj;
}
set { ViewState["HasAccess"] = value;}
}
private string _resourceName;
/// <summary>
/// Property ResourceName (string)
/// </summary>
public string ResourceName
{
get { return this._resourceName; }
set { this._resourceName = value; }
}
private string _securityResourceName;
/// <summary>
/// Property SecurityResourceName (string)
/// </summary>
public string SecurityResourceName
{
get { return this._securityResourceName; }
set { this._securityResourceName = value; }
}
private string _unAuthorizedResourceName;
/// <summary>
/// Property UnAuthorizedResourceName (string)
/// </summary>
public string UnAuthorizedResourceName
{
get { return this._unAuthorizedResourceName; }
set { this._unAuthorizedResourceName = value; }
}
private string _location;
/// <summary>
/// Property Location (string)
/// </summary>
public string Location
{
get { return this._location; }
set { this._location = value; }
}
protected override void OnPreRender(EventArgs e)
{
if(!HasAccess)
{
string path = Globals.GetSiteUrls().Locations[Location];
directoryAccess = WebDirectory.ValidateAccess(path);
switch(directoryAccess)
{
case DirectoryAccess.Success:
HasAccess = true;
break;
case DirectoryAccess.SecurityException:
this.Text = (SecurityResourceName != null) ? ResourceManager.GetString(SecurityResourceName) : ResourceManager.GetString(ResourceName);
break;
case DirectoryAccess.UnauthorizedAccessException:
this.Text = (UnAuthorizedResourceName != null) ? ResourceManager.GetString(UnAuthorizedResourceName) : ResourceManager.GetString(ResourceName);
break;
}
}
base.OnPreRender (e);
}
protected override void Render(HtmlTextWriter writer)
{
if(!HasAccess)
base.Render(writer);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -