doc: engine

oneRain 2021-04-20 11:58:41 +08:00
parent 765b301d40
commit ae923b2691
8 changed files with 43 additions and 6 deletions

View File

@ -10,6 +10,10 @@ namespace LeanCloud.Engine {
AfterDelete
}
/// <summary>
/// LCEngineClassHookAttribute is an attribute that hooks class in engine.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class LCEngineClassHookAttribute : Attribute {
public string ClassName {
get;

View File

@ -1,6 +1,9 @@
using System;
namespace LeanCloud.Engine {
/// <summary>
/// LCEngineFunctionAttribute is an attribute of cloud function in engine.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class LCEngineFunctionAttribute : Attribute {
public string FunctionName {

View File

@ -1,6 +1,9 @@
using System;
namespace LeanCloud.Engine {
/// <summary>
/// LCEngineFunctionParamAttribute is an attribute of the parameter of cloud function in engine.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)]
public class LCEngineFunctionParamAttribute : Attribute {
public string ParamName {

View File

@ -20,6 +20,10 @@ namespace LeanCloud.Engine {
ClientOffline,
}
/// <summary>
/// LCEngineRealtimeHookAttribute is an attribute that hooks realtime in engine.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class LCEngineRealtimeHookAttribute : Attribute {
public LCEngineRealtimeHookType HookType {
get;

View File

@ -7,6 +7,10 @@ namespace LeanCloud.Engine {
OnLogin
}
/// <summary>
/// LCEngineUserHookAttribute is an attribute that hooks user in engine.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class LCEngineUserHookAttribute : Attribute {
public LCEngineUserHookType HookType {
get;

View File

@ -11,6 +11,9 @@ using Microsoft.Extensions.DependencyInjection;
using LeanCloud.Common;
namespace LeanCloud.Engine {
/// <summary>
/// LCEngine provides the initialization of Engine in LeanCloud.
/// </summary>
public class LCEngine {
public const string LCEngineCORS = "LCEngineCORS";
@ -79,6 +82,10 @@ namespace LeanCloud.Engine {
public static Dictionary<string, MethodInfo> ClassHooks = new Dictionary<string, MethodInfo>();
public static Dictionary<string, MethodInfo> UserHooks = new Dictionary<string, MethodInfo>();
/// <summary>
/// Initializes the engine with the given services.
/// </summary>
/// <param name="services"></param>
public static void Initialize(IServiceCollection services) {
// 获取环境变量
LCLogger.Debug("-------------------------------------------------");
@ -198,7 +205,7 @@ namespace LeanCloud.Engine {
});
}
public static void PrintEnvironmentVar(string key) {
private static void PrintEnvironmentVar(string key) {
LCLogger.Debug($"{key} : {Environment.GetEnvironmentVariable(key)}");
}
@ -293,7 +300,7 @@ namespace LeanCloud.Engine {
}
}
public static object GetFunctions(HttpRequest request) {
internal static object GetFunctions(HttpRequest request) {
CheckMasterKey(request);
List<string> functions = new List<string>();

View File

@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading;
using LeanCloud.Storage;
namespace LeanCloud.Engine {
/// <summary>
/// LCEngineRequestContext provides the context of engine request.
/// </summary>
public class LCEngineRequestContext {
public const string RemoteAddressKey = "__remoteAddressKey";
public const string SessionTokenKey = "__sessionToken";
@ -32,6 +34,9 @@ namespace LeanCloud.Engine {
return requestContext.Value[key];
}
/// <summary>
/// The remote address of this request.
/// </summary>
public static string RemoteAddress {
get {
object remoteAddress = Get(RemoteAddressKey);
@ -45,6 +50,9 @@ namespace LeanCloud.Engine {
}
}
/// <summary>
/// The session token of this request.
/// </summary>
public static string SessionToken {
get {
object sessionToken = Get(SessionTokenKey);
@ -58,6 +66,9 @@ namespace LeanCloud.Engine {
}
}
/// <summary>
/// The user of this request.
/// </summary>
public static LCUser CurrentUser {
get {
object currentUser = Get(CurrentUserKey);

View File

@ -6,7 +6,8 @@ using LeanCloud.Storage.Internal.Object;
namespace LeanCloud.Storage {
/// <summary>
/// LeanEngine
/// LCCloud contains static functions that call the cloud functions of Engine
/// in LeanCloud.
/// </summary>
public static class LCCloud {
private const string PRODUCTION_KEY = "X-LC-Prod";