⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 permissionrepater.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CommunityServer.Components;

namespace CommunityServer.Controls
{
    public enum DisplayMode 
    {
        All = 0,
        Implicit= 1,
        Explicit = 2
    }

    [
        ParseChildren(true)	
    ]
    /// <summary>
    /// Base class for display Permissions on a control
    /// </summary>
    public abstract class PermissionRepater : Repeater 
    {

        CSContext csContext = CSContext.Current;
        string skinName = null;
        DisplayMode displayMode = DisplayMode.All;
        int sectionID = -1;

        // *********************************************************************
        //  ForumRepeaterControl
        //
        /// <summary>
        /// Constructor
        /// </summary>
        // ***********************************************************************/
        public PermissionRepater() 
        {

            // If we're in design-time we simply return
            if (null == HttpContext.Current)
                return;
        }

        public DisplayMode DisplayMode 
        {
            get{ return displayMode; }
            set{ displayMode = value; }
        }

        protected abstract ArrayList GetPermissions(int sectionId);

        // *********************************************************************
        //  CreateChildControls
        //
        /// <summary>
        /// Override create child controls
        /// </summary>
        /// 
        // ********************************************************************/   
        protected override void CreateChildControls() 
        {
            EnableViewState = false;
            ArrayList roles = null;
            ArrayList displayRoles = null;

            roles = GetPermissions(sectionID);

            if( DisplayMode != DisplayMode.All ) 
            {
                displayRoles = new ArrayList();
                bool displayImplied = DisplayMode == DisplayMode.Implicit? true : false;

                foreach( PermissionBase pb in roles ) 
                {
                    if( pb.Implied == displayImplied ) 
                    {
                        displayRoles.Add( pb );
                    }
                }
            }
            else 
            {
                displayRoles = roles;
            }

            if (( roles != null) && (roles.Count != 0 )) 
            {
                this.DataSource = displayRoles;
                this.DataBind();
            }
        }
        
        // *********************************************************************
        //  ForumID  
        //
        /// <summary>
        /// Used to get the appropriate roles
        /// </summary>
        /// 
        // ********************************************************************/ 
        public int SectionID  
        {
            get  
            {
                return sectionID;
            }
            set  
            {
                sectionID = value;
            }
        }
        
        // *********************************************************************
        //  SkinName
        //
        /// <summary>
        /// Used to construct paths to images, etc. within controls.
        /// </summary>
        /// 
        // ********************************************************************/ 
        protected string SkinName 
        {
            get 
            {
                return skinName;
            }
            set 
            {
                skinName = value;
            }
        }

    }

}

⌨️ 快捷键说明

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