globals.cs
来自「微软的.NET论坛的源代码(COOL!!!)」· CS 代码 · 共 1,022 行 · 第 1/3 页
CS
1,022 行
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlHome"].Replace("^", "&");
}
}
/// <summary>
/// Returns the Url to my forums
/// </summary>
static public String UrlMyForums {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlMyForums"].Replace("^", "&");
}
}
/// <summary>
/// Returns the Url to change the user's password
/// </summary>
static public String UrlChangePassword {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlChangePassword"].Replace("^", "&");
}
}
/// <summary>
/// Returns the Url to change the user's password
/// </summary>
static public String UrlForgotPassword {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlForgotPassword"].Replace("^", "&");
}
}
/// <summary>
/// Returns the Url to search for all posts by a given user
/// </summary>
static public String UrlSearchForPostsByUser {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlSearchForUser"].Replace("^", "&");
}
}
/// <summary>
/// Returns the Url to view all users
/// </summary>
static public String UrlShowAllUsers {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlShowAllUsers"];
}
}
/// <summary>
/// Returns the Url to edit an existing post from the post moderation page
/// </summary>
static public String UrlEditPost {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlEditPost"].Replace("^", "&");
}
}
/// <summary>
/// Returns the Url to edit an existing post from the post moderation page
/// </summary>
static public String UrlUserEditPost {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlUserEditPost"].Replace("^", "&");
}
}
/// <summary>
/// Returns the Url to edit an existing post from the post moderation page
/// </summary>
static public String UrlDeletePost {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlDeletePost"].Replace("^", "&");
}
}
/// <summary>
/// Returns the Url to edit an existing post from the post moderation page
/// </summary>
static public String UrlMovePost {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlMovePost"].Replace("^", "&");
}
}
static public String UrlModerateForumPosts {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlModerateForumPosts"].Replace("^", "&");
}
}
static public String UrlModerateThread {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlModerateThread"].Replace("^", "&");
}
}
static public String UrlManageForumPosts {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlManageForumPosts"].Replace("^", "&");
}
}
/// <summary>
/// Returns the Url to edit an existing post from the administration page
/// </summary>
static public String UrlEditPostFromAdmin {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlEditExistingPostFromAdmin"].Replace("^", "&");
}
}
/// <summary>
/// Returns the Url to login to the forum site
/// </summary>
static public String UrlLogin {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlLogin"];
}
}
/// <summary>
/// Returns the Url to login to the forum site
/// </summary>
static public String UrlLogout {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlLogout"];
}
}
/// <summary>
/// Returns the Url to show a particular forum
/// </summary>
static public String UrlShowForum {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlShowForum"].Replace("^", "&");
}
}
/// <summary>
/// <summary>
/// Returns the Url to show a particular forum group
/// </summary>
static public String UrlShowForumGroup {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlShowForumGroup"].Replace("^", "&");
}
}
/// Returns the Url to show a particular post
/// </summary>
static public String UrlShowPost {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlShowPost"].Replace("^", "&");
}
}
/// <summary>
/// Returns the Url to the post moderation page
/// </summary>
static public String UrlModeration {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlModeration"].Replace("^", "&");
}
}
/// <summary>
/// Returns the path to the location of the various message Web pages. The
/// message pages are pages that are automatically shown at certain events, such
/// as when a user posts a message to a moderated forum, or when a user attempts
/// to view a post that doesn't exist.
/// </summary>
static public String UrlMessage {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlMessage"].Replace("^", "&");
}
}
/// <summary>
/// Specifies the Url to reply to a post
/// </summary>
static public String UrlReplyToPost {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlReplyToPost"].Replace("^", "&");
}
}
/// <summary>
/// Indicates the Url to add a new post
/// </summary>
static public String UrlAddNewPost {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlAddNewPost"].Replace("^", "&");
}
}
/// <summary>
/// Indicates the Url to edit a forum
/// </summary>
static public String UrlEditForum {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlEditForum"].Replace("^", "&");
}
}
/// <summary>
/// Indicates the Url to create a new forum
/// </summary>
static public String UrlCreateForum {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlCreateForum"].Replace("^", "&");
}
}
/// <summary>
/// Indicates the Url to show a forum's posts for editing and deleting purposes
/// </summary>
static public String UrlShowForumPostsForAdmin {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlShowForumPostsForAdmin"].Replace("^", "&");
}
}
/// <summary>
/// The Url to use for Admin
/// </summary>
static public String UrlAdmin {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlAdmin"].Replace("^", "&");
}
}
/// <summary>
/// The Url to use for Admins to edit users
/// </summary>
static public String UrlAdminEditUser {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["urlAdminEditUser"].Replace("^", "&");
}
}
/// <summary>
/// Indicates the name of the Web site.
/// </summary>
static public String SiteName {
get {
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
return configSettings["siteName"];
}
}
/// <summary>
/// Indicates the physical path to the transformation text file.
/// </summary>
static public String PhysicalPathToTransformationFile {
get {
if (HttpContext.Current.Cache["pathToTransformationFile"] == null) {
string path;
NameValueCollection configSettings = (NameValueCollection) ConfigurationSettings.GetConfig("AspNetForumsSettings");
path = configSettings["pathToTransformationFile"];
if (path.Substring(0,1) == "/")
// using virtual path, must convert to physical path
path = HttpContext.Current.Server.MapPath(path);
HttpContext.Current.Cache.Insert("pathToTransformationFile", path);
return path;
} else {
return (string) HttpContext.Current.Cache["pathToTransformationFile"];
}
}
}
/// <summary>
/// Creates a temporary password of a specified length.
/// </summary>
/// <param name="length">The maximum length of the temporary password to create.</param>
/// <returns>A temporary password less than or equal to the length specified.</returns>
public static String CreateTemporaryPassword(int length) {
// begin by creating a random password
// start off by getting a temp filename
String strTempPassword = Path.GetFileNameWithoutExtension(Path.GetTempFileName()) + DateTime.Now.Millisecond.ToString();
// jumble up the password
Random rnd = new Random();
const int RandomLoops = 3;
int iRandNumber = 0;
for (int iLoop=0; iLoop < RandomLoops; iLoop++) {
iRandNumber = rnd.Next(strTempPassword.Length-3);
if (iLoop % 2 == 0)
strTempPassword += strTempPassword.Substring(iRandNumber, rnd.Next(iRandNumber, strTempPassword.Length-1) -iRandNumber);
else
strTempPassword = strTempPassword.Substring(iRandNumber, rnd.Next(iRandNumber, strTempPassword.Length-1) - iRandNumber) + strTempPassword;
}
// make sure the password is only 10 characters long, at most
if (strTempPassword.Length > length)
strTempPassword = strTempPassword.Substring(0, length);
return strTempPassword;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?