📄 extensionmodule.cs
字号:
//------------------------------------------------------------------------------
// <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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -