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

📄 texteditorloader.cs

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

using System;
using System.Collections;
using System.Reflection;
using System.Web;
using CommunityServer.Configuration;

namespace CommunityServer.Controls
{
	/// <summary>
	/// Summary description for TextEditorLoader.
	/// </summary>
	public class TextEditorLoader
	{
        //holder
        private static ConstructorInfo iTextConstructorInfo = null;
		private static ConstructorInfo defaultITextConstructorInfo = null;
		
		

        //Can not be instantiated
		private TextEditorLoader(){}

        //Lets do this only once per appStart
		static TextEditorLoader()
		{
			iTextConstructorInfo = Load(CSConfiguration.GetConfig().TextEditorType);
			defaultITextConstructorInfo = Load(null);


		}

        //Get CnstrInfo for quick reloading
        static ConstructorInfo Load(string configType)
        {
            if(configType == null)
            {
                configType = typeof(CommunityServer.Controls.DefaultTextEditor).ToString();
            }

            Type controlType = Type.GetType(configType);
            if(controlType == null)
            {
                throw new Exception(string.Format("The Type {0} could not be loaded by the TextEditorLoader", configType));
            }

            return controlType.GetConstructor(new Type[0]);
        }

		

        //Get new Instance
        public static ITextEditor Instance(HttpContext context, string[] roles)
        {

			//Should we load our internal control?
			bool loadDefault = true;

			if(roles != null && roles.Length > 0 && roles[0].Trim().Length > 0)
			{
				foreach(string role in roles)
				{
					if(context.User.IsInRole(role))
					{
						loadDefault = false;
						break;
					}
				}
			}
			else
				loadDefault = false;

			if(!loadDefault)
			{
				if(iTextConstructorInfo != null)
				{
					return (ITextEditor)iTextConstructorInfo.Invoke(null);
				}
			}

			return (ITextEditor)defaultITextConstructorInfo.Invoke(null);
        }

  
        // Should only be used for debugging
        public static ITextEditor CreateInstance(string configType)
        {
            return (ITextEditor)Activator.CreateInstance(Type.GetType(configType));
        }
	}
}

⌨️ 快捷键说明

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