extensionmodule.cs
来自「本系统是在asp版《在线文件管理器》的基础上设计制作」· CS 代码 · 共 62 行
CS
62 行
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
using CommunityServer.Configuration;
namespace CommunityServer.Components
{
public abstract class ExtensionModule
{
public abstract void Init (Provider provider);
public abstract void ProcessRequest();
public static ExtensionModule Instance (Provider provider)
{
try
{
if(provider == null)
return null;
// Use the cache because the reflection used later is expensive
//
string cacheKey = "Module-" + provider.Name;
ConstructorInfo constructor = CSCache.Get(cacheKey) as ConstructorInfo;
ExtensionModule module = null;
// Is the module already cached?
//
if(constructor == null)
{
Type type = Type.GetType( provider.Type );
if(type == null)
return null;
constructor = type.GetConstructor(Type.EmptyTypes);
// Insert the type into the cache
//
CSCache.Max(cacheKey, constructor); //Did not have a cache time specified
}
module = (ExtensionModule)constructor.Invoke(null);
// Initialize the module for the request
//
module.Init(provider);
return module;
}
catch
{
return null;
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?