📄 webboxutility.cs
字号:
namespace ASPNET.StarterKit.Communities {
using System;
using System.IO;
using System.Web;
using System.Collections;
//*********************************************************************
//
// WebBoxUtility Class
//
// Contains static methods for working with Web Boxes.
//
//*********************************************************************
public class WebBoxUtility {
//*********************************************************************
//
// GetAllWebBoxes Method
//
// Returns list of all available Web Boxes.
//
//*********************************************************************
public static string[] GetAllWebBoxes() {
ArrayList colWebBoxes = new ArrayList();
// Get contents from common folder
string webBoxFolder = HttpContext.Current.Server.MapPath( CommunityGlobals.AppPath + "/Communities/Common/WebBoxes" );
string[] arrWebBoxFiles = Directory.GetFiles( webBoxFolder, "*.ascx" );
foreach (string strFileName in arrWebBoxFiles)
colWebBoxes.Add( Path.GetFileNameWithoutExtension( strFileName ) );
// Get contents from community folder
webBoxFolder = HttpContext.Current.Server.MapPath( String.Format("{0}/Communities/{1}/WebBoxes/", CommunityGlobals.AppPath, CommunityGlobals.CommunityName) );
if (Directory.Exists(webBoxFolder)) {
arrWebBoxFiles = Directory.GetFiles( webBoxFolder, "*.ascx" );
foreach (string strFileName in arrWebBoxFiles)
colWebBoxes.Add(String.Format("{0} ({1})", Path.GetFileNameWithoutExtension(strFileName), CommunityGlobals.CommunityName));
}
return (string[])colWebBoxes.ToArray(typeof(String));
}
public static string GetWebBoxPath(string webBox) {
string communityIdentifier = String.Format(" ({0})", CommunityGlobals.CommunityName);
if (webBox.EndsWith(communityIdentifier))
return String.Format("~/Communities/{0}/WebBoxes/{1}.ascx", CommunityGlobals.CommunityName, webBox.Replace(communityIdentifier,""));
else
return String.Format("~/Communities/Common/WebBoxes/{0}.ascx", webBox);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -