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 AfterDelete
} }
/// <summary>
/// LCEngineClassHookAttribute is an attribute that hooks class in engine.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class LCEngineClassHookAttribute : Attribute { public class LCEngineClassHookAttribute : Attribute {
public string ClassName { public string ClassName {
get; get;

View File

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

View File

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

View File

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

View File

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

View File

@ -11,6 +11,9 @@ using Microsoft.Extensions.DependencyInjection;
using LeanCloud.Common; using LeanCloud.Common;
namespace LeanCloud.Engine { namespace LeanCloud.Engine {
/// <summary>
/// LCEngine provides the initialization of Engine in LeanCloud.
/// </summary>
public class LCEngine { public class LCEngine {
public const string LCEngineCORS = "LCEngineCORS"; 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> ClassHooks = new Dictionary<string, MethodInfo>();
public static Dictionary<string, MethodInfo> UserHooks = 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) { public static void Initialize(IServiceCollection services) {
// 获取环境变量 // 获取环境变量
LCLogger.Debug("-------------------------------------------------"); 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)}"); 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); CheckMasterKey(request);
List<string> functions = new List<string>(); 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 System.Threading;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace LeanCloud.Engine { namespace LeanCloud.Engine {
/// <summary>
/// LCEngineRequestContext provides the context of engine request.
/// </summary>
public class LCEngineRequestContext { public class LCEngineRequestContext {
public const string RemoteAddressKey = "__remoteAddressKey"; public const string RemoteAddressKey = "__remoteAddressKey";
public const string SessionTokenKey = "__sessionToken"; public const string SessionTokenKey = "__sessionToken";
@ -32,6 +34,9 @@ namespace LeanCloud.Engine {
return requestContext.Value[key]; return requestContext.Value[key];
} }
/// <summary>
/// The remote address of this request.
/// </summary>
public static string RemoteAddress { public static string RemoteAddress {
get { get {
object remoteAddress = Get(RemoteAddressKey); object remoteAddress = Get(RemoteAddressKey);
@ -45,6 +50,9 @@ namespace LeanCloud.Engine {
} }
} }
/// <summary>
/// The session token of this request.
/// </summary>
public static string SessionToken { public static string SessionToken {
get { get {
object sessionToken = Get(SessionTokenKey); object sessionToken = Get(SessionTokenKey);
@ -58,6 +66,9 @@ namespace LeanCloud.Engine {
} }
} }
/// <summary>
/// The user of this request.
/// </summary>
public static LCUser CurrentUser { public static LCUser CurrentUser {
get { get {
object currentUser = Get(CurrentUserKey); object currentUser = Get(CurrentUserKey);

View File

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