globals.cs

来自「微软的.NET论坛的源代码(COOL!!!)」· CS 代码 · 共 1,022 行 · 第 1/3 页

CS
1,022
字号
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Drawing;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Xml;
using System.Web.Caching;
using System.Text.RegularExpressions;


namespace AspNetForums.Components {
    /************* DECLARE ENUMERATIONS ****************/
    /// <summary>
    /// The NextPrevMessagesPosition enumeration is used with the ForumView Web control to indicate the position of the
    /// Next/Prev Messages links.  The available options are Top, Bottom, and Both.
    /// </summary>
    public enum NextPrevMessagesPosition { 
        /// <summary>
        /// Places the Next/Prev Messages bar just at the top of the forum post listing.
        /// </summary>
        Top, 
		
        /// <summary>
        /// Places the Next/Prev Messages bar just at the bottom of the forum post listing.
        /// </summary>
        Bottom, 
		
        /// <summary>
        /// Places the Next/Prev Messages bar at the top and the bottom of the forum post listing.
        /// </summary>
        Both,
	
        /// <summary>
        /// Does not display the Next/Prev Messages bar.
        /// </summary>
        None
    }

    /// <summary>
    /// The ViewOptions enumeration determines how the posts for a particular forum are displayed.
    /// The options are NotSet, meaning the default is used; Flat; Mixed; and Threaded.
    /// </summary>
    public enum ViewOptions { 
        /// <summary>
        /// When the forum is visited by an anonymous user, their ViewOptions are NotSet.
        /// Pass this value in to have the default forum view setting used.
        /// </summary>
        NotSet = -1, 
		
        /// <summary>
        /// Specifies to display the forum in a Flat mode.
        /// </summary>
        Flat = 0, 
		
        /// <summary>
        /// Specifies to display the forum in the Mixed mode.
        /// </summary>
        Mixed = 1, 
		
        /// <summary>
        /// Specifies to display the forum in Threaded mode.
        /// </summary>
        Threaded = 2 }

    /// <summary>
    /// The CreateEditPostMode enumeration determines what mode the PostDisplay Web control assumes.
    /// The options are NewPost, ReplyToPost, and EditPost.
    /// </summary>
    public enum CreateEditPostMode { 
        /// <summary>
        /// Specifies that the user is creating a new post.
        /// </summary>
        NewPost, 
		
        /// <summary>
        /// Specifies that the user is replying to an existing post.
        /// </summary>
        ReplyToPost, 
		
        /// <summary>
        /// Specifies that a  moderator or administrator is editing an existing post.
        /// </summary>
        EditPost }

    /// <summary>
    /// The CreateEditForumMode enumeration determines what mode the CreateEditForum Web control assumes.
    /// The options are CreateForum and EditForum.
    /// </summary>
    public enum CreateEditForumMode { 
        /// <summary>
        /// Specifies that a new forum is being created.
        /// </summary>
        CreateForum, 
		
        /// <summary>
        /// Specifies that an existing forum is being edited.
        /// </summary>
        EditForum }

    /// <summary>
    /// The DateTimeFormatEnum enumeration determines the date/time format returned by the AccountForTimezone
    /// functions.  The available options are: ShortTimeString; ShortDateString; LongTimeString;
    /// LongDateString, and CompleteDate.
    /// </summary>
    public enum DateTimeFormatEnum { ShortTimeString, ShortDateString, LongTimeString, LongDateString, CompleteDate }

    /// <summary>
    /// The ModeratedForumMode enumeration determines how the ModeratedForums Web control works.
    /// A value of ViewForForum shows all of the moderators for a particular forum; a value of ViewForUser
    /// shows all of the forums a particular user moderates.
    /// </summary>
    public enum ModeratedForumMode { 
        /// <summary>
        /// Specifies to view the list of moderators for a particular forum.
        /// </summary>
        ViewForForum,
 
        /// <summary>
        /// Specifies to view a list of moderated forums for a particular user.
        /// </summary>
        ViewForUser }

    /// <summary>
    /// The UserInfoEditMode enumeration determines the role the UserInfo Web control assumes.  The
    /// available options are Edit and View.
    /// </summary>
    public enum UserInfoEditMode { 
        /// <summary>
        /// Indicates that the user is editing his or her personal user information.
        /// </summary>
        Edit, 
		
        /// <summary>
        /// Indicates that a user is viewing a user's information (not necessarily his or her own).
        /// </summary>
        View,

        /// <summary>
        /// Indicates that the user is being edited by the admin or moderator.
        /// </summary>
        Admin

    }


    /// <summary>
    /// Indicates how to apply the search query terms.
    /// </summary>
    public enum ToSearchEnum { 
        /// <summary>
        /// Specifies that the PerformSearch method should apply the search query to the post body.
        /// </summary>
        PostsSearch, 
		
        /// <summary>
        /// Specifies that the PerformSearch method should apply the search query to the post's author's 
        /// Username.
        /// </summary>
        PostsBySearch }

    /// <summary>
    /// Indicates the return status for creating a new user.
    /// </summary>
    public enum CreateUserStatus { 
        /// <summary>
        /// The user was not created for some unknown reason.
        /// </summary>
        UnknownFailure, 
		
        /// <summary>
        /// The user's account was successfully created.
        /// </summary>
        Created, 
		
        /// <summary>
        /// The user's account was not created because the user's desired username is already being used.
        /// </summary>
        DuplicateUsername, 
		
        /// <summary>
        /// The user's account was not created because the user's email address is already being used.
        /// </summary>
        DuplicateEmailAddress, 
		
        /// <summary>
        /// The user's account was not created because the user's desired username did not being with an
        /// alphabetic character.
        /// </summary>
        InvalidFirstCharacter }

    /// <summary>
    /// Indicates how to interpret the search terms.
    /// </summary>
    public enum SearchWhatEnum { 
        /// <summary>
        /// Searches for all words entered into the search terms.
        /// </summary>
        SearchAllWords, 
		
        /// <summary>
        /// Searches for any word entered as search terms.
        /// </summary>
        SearchAnyWord, 
		
        /// <summary>
        /// Searches for the EXACT search phrase entered in the search terms.
        /// </summary>
        SearchExactPhrase }

    /// <summary>
    /// Returns the status of a moved post operation.
    /// </summary>
    public enum MovedPostStatus { 
        /// <summary>
        /// The post was not moved; this could happen due to the post having been already deleted or
        /// already approved by another moderator.
        /// </summary>
        NotMoved, 
		
        /// <summary>
        /// The post was moved successfully to the specified forum, but is still waiting approval, since
        /// the moderator who moved the post lacked moderation rights to the forum the post was moved to.
        /// </summary>
        MovedButNotApproved, 
		
        /// <summary>
        /// The post was moved successfully to the specified forum and approved.
        /// </summary>
        MovedAndApproved}


    /// <summary>
    /// The EmailTypeEnum enumeration determines what type of message is to be displayed
    /// </summary>
    public enum Messages {
        UnableToAdminister = 1,
        UnableToEditPost = 2,
        UnableToModerate = 3,
        DuplicatePost = 4,
        FileNotFound = 5,
        UnknownForum = 6,
        NewAccountCreated = 7,
        PostPendingModeration = 8,
        PostDoesNotExist = 9,
        PostIdParameterNotSpecified = 10,
        ProblemPosting = 11,
        UnableToViewMessage = 12,
        UserProfileUpdated = 13,
        UserDoesNotExist = 14,
        UserPasswordChangeSuccess = 15,
        UserPasswordChangeFailed = 16
    }

    /// <summary>
    /// The EmailTypeEnum enumeration determines what type of email template is used to send an email.
    /// The available options are: ForgottenPassword, ChangedPassword, NewMessagePostedToThread,
    /// NewUserAccountCreated, MessageApproved, MessageMovedAndApproved, MessageMovedAndNotApproved,
    /// MessageDeleted, and ModeratorEmailNotification.
    /// </summary>
    public enum EmailTypeEnum {
        /// <summary>
        /// Sends a user their username and password to the email address on file.
        /// </summary>
        ForgottenPassword = 1,

        /// <summary>
        /// Sends an email to the user when he changes his password.
        /// </summary>
        ChangedPassword = 2,

        /// <summary>
        /// Sends a mass emailing when a new post is added to a thread.  Those who receive the email are those
        /// who have email thread tracking turned on for the particular thread that the new post was added to.
        /// </summary>
        NewMessagePostedToThread = 3,

        /// <summary>
        /// When a user creates a new account, this email template sends their UrlShowPost information (username/password).
        /// </summary>
        NewUserAccountCreated = 4,

        /// <summary>
        /// When a user's post that was awaiting moderation is approved, they are sent this email.
        /// </summary>
        MessageApproved = 5,

        /// <summary>
        /// If a user's post is moved from one forum to another, this email indicates this fact.
        /// </summary>
        MessageMovedAndApproved = 6,

        /// <summary>
        /// If a user's post was moved to another forum but is still waiting moderator approval, this
        /// email template informs them of the situation.
        /// </summary>
        MessageMovedAndNotApproved = 7,

        /// <summary>
        /// If a user's post is deleted, this email explains why their post was deleted.
        /// </summary>
        MessageDeleted = 8,

        /// <summary>
        /// When a new post needs to be approved, those moderators of the posted-to forum who have email
        /// notification turned on are sent this email to instruct them that there is a post waiting moderation.
        /// </summary>
        ModeratorEmailNotification = 9
    }
    /***************************************************/

    public class Globals {
	
        // the HTML newline character
        public const String HtmlNewLine = "<br />";
		
        public const String _appSettingsPrefix = "AspNetForumsSettings.";

        // *********************************************************************
        //  LoadSkinnedTemplate
        //
        /// <summary>
        /// Attempts to load a template from the skin defined for the application.
        /// If no template is found, or if an error occurs, a maker is added to the
        /// cache to indicate that we won't try the code path again. Otherwise the
        /// template is added to the cache and loaded from memory.
        /// </summary>
        /// 
        // ********************************************************************/
        public static ITemplate LoadSkinnedTemplate(string virtualPathToTemplate, string templateKey, Page page) {

            ITemplate _template;
            CacheDependency fileDep;
            HttpContext Context = HttpContext.Current;

            // Get the instance of the Cache
            Cache Cache = Context.Cache;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?