webboxutility.cs

来自「C#邮件代码库,用于邮件发送」· CS 代码 · 共 64 行

CS
64
字号
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 + =
减小字号Ctrl + -
显示快捷键?