diff --git a/Engine/Attributes/LCEngineUserHookAttribute.cs b/Engine/Attributes/LCEngineUserHookAttribute.cs index 00146d3..c9485f1 100644 --- a/Engine/Attributes/LCEngineUserHookAttribute.cs +++ b/Engine/Attributes/LCEngineUserHookAttribute.cs @@ -2,8 +2,8 @@ namespace LeanCloud.Engine { public enum LCEngineUserHookType { - SMS, - Email, + OnSMSVerified, + OnEmailVerified, OnLogin } diff --git a/Engine/Handlers/LCPingHandler.cs b/Engine/Handlers/LCPingHandler.cs index dce428d..b00dd69 100644 --- a/Engine/Handlers/LCPingHandler.cs +++ b/Engine/Handlers/LCPingHandler.cs @@ -5,7 +5,7 @@ namespace LeanCloud.Engine { public static object HandlePing() { LCLogger.Debug("Ping ~~~"); return new Dictionary { - { "runtime", "dotnet" }, + { "runtime", "dotnet-3.1" }, { "version", LCApplication.SDKVersion } }; } diff --git a/Engine/LCEngine.cs b/Engine/LCEngine.cs index cadbae2..67443e7 100644 --- a/Engine/LCEngine.cs +++ b/Engine/LCEngine.cs @@ -96,9 +96,9 @@ namespace LeanCloud.Engine { .ToDictionary(mi => { LCEngineUserHookAttribute attr = mi.GetCustomAttribute(); switch (attr.HookType) { - case LCEngineUserHookType.SMS: + case LCEngineUserHookType.OnSMSVerified: return OnSMSVerified; - case LCEngineUserHookType.Email: + case LCEngineUserHookType.OnEmailVerified: return OnEmailVerified; case LCEngineUserHookType.OnLogin: return OnLogin; diff --git a/Sample/LeanEngineApp/Controllers/FunctionController.cs b/Sample/LeanEngineApp/Controllers/FunctionController.cs new file mode 100644 index 0000000..f10cbc6 --- /dev/null +++ b/Sample/LeanEngineApp/Controllers/FunctionController.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +namespace LeanEngineApp.Controllers { + [ApiController] + [Route("{1,1.1}/functions/")] + public class FunctionController : ControllerBase { + public FunctionController() { + } + + [HttpGet("_ops/metadatas")] + public Dictionary> Get() { + List functions = new List { + + }; + return new Dictionary> { + { "result", functions } + }; + } + + public async Task Post() { + return null; + } + } +} diff --git a/Sample/LeanEngineApp/Controllers/PingController.cs b/Sample/LeanEngineApp/Controllers/PingController.cs new file mode 100644 index 0000000..74d9ab5 --- /dev/null +++ b/Sample/LeanEngineApp/Controllers/PingController.cs @@ -0,0 +1,27 @@ +using System; +using System.Threading; +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace LeanEngineApp.Controllers { + [ApiController] + [Route("__engine/{1,1.1}/ping")] + public class PingController : ControllerBase { + private readonly ILogger logger; + + public PingController(ILogger logger) { + this.logger = logger; + } + + [HttpGet] + public Dictionary Get() { + Console.WriteLine("ping get to console"); + logger.LogDebug("ping get to logger"); + return new Dictionary { + { "runtime", "dotnet" }, + { "version", "1.0.0" } + }; + } + } +} diff --git a/Sample/LeanEngineApp/Controllers/WeatherForecastController.cs b/Sample/LeanEngineApp/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..c08cdf9 --- /dev/null +++ b/Sample/LeanEngineApp/Controllers/WeatherForecastController.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace LeanEngineApp.Controllers { + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) { + _logger = logger; + } + + [HttpGet] + public IEnumerable Get() { + var rng = new Random(); + return Enumerable.Range(1, 5).Select(index => new WeatherForecast { + Date = DateTime.Now.AddDays(index), + TemperatureC = rng.Next(-20, 55), + Summary = Summaries[rng.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/Sample/LeanEngineApp/LeanEngine/CloudFunctionAttribute.cs b/Sample/LeanEngineApp/LeanEngine/CloudFunctionAttribute.cs new file mode 100644 index 0000000..110ca8a --- /dev/null +++ b/Sample/LeanEngineApp/LeanEngine/CloudFunctionAttribute.cs @@ -0,0 +1,14 @@ +using System; + +namespace LeanEngineApp.LeanEngine { + [AttributeUsage(AttributeTargets.Method)] + public class CloudFunctionAttribute : Attribute { + public string Name { + get; + } + + public CloudFunctionAttribute(string name) { + Name = name; + } + } +} diff --git a/Sample/LeanEngineApp/LeanEngine/LeanEngine.cs b/Sample/LeanEngineApp/LeanEngine/LeanEngine.cs new file mode 100644 index 0000000..9509018 --- /dev/null +++ b/Sample/LeanEngineApp/LeanEngine/LeanEngine.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; + +namespace LeanEngineApp.LeanEngine { + public class LeanEngine { + private Dictionary dict; + + public LeanEngine() { + + } + } +} diff --git a/Sample/LeanEngineApp/LeanEngineApp.csproj b/Sample/LeanEngineApp/LeanEngineApp.csproj new file mode 100644 index 0000000..b0f0402 --- /dev/null +++ b/Sample/LeanEngineApp/LeanEngineApp.csproj @@ -0,0 +1,12 @@ + + + + netcoreapp3.1 + 0.6.4 + + + + + + + diff --git a/Sample/LeanEngineApp/Program.cs b/Sample/LeanEngineApp/Program.cs new file mode 100644 index 0000000..e5fb3c9 --- /dev/null +++ b/Sample/LeanEngineApp/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace LeanEngineApp { + public class Program { + public static void Main(string[] args) { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { + webBuilder.UseStartup(); + }); + } +} diff --git a/Sample/LeanEngineApp/Startup.cs b/Sample/LeanEngineApp/Startup.cs new file mode 100644 index 0000000..7726e01 --- /dev/null +++ b/Sample/LeanEngineApp/Startup.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace LeanEngineApp { + public class Startup { + public Startup(IConfiguration configuration) { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) { + services.AddControllers(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { + if (env.IsDevelopment()) { + app.UseDeveloperExceptionPage(); + } + + app.UseHttpsRedirection(); + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => { + endpoints.MapControllers(); + }); + } + } +} diff --git a/Sample/LeanEngineApp/WeatherForecast.cs b/Sample/LeanEngineApp/WeatherForecast.cs new file mode 100644 index 0000000..5257525 --- /dev/null +++ b/Sample/LeanEngineApp/WeatherForecast.cs @@ -0,0 +1,13 @@ +using System; + +namespace LeanEngineApp { + public class WeatherForecast { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string Summary { get; set; } + } +} diff --git a/Sample/LeanEngineApp/appsettings.Development.json b/Sample/LeanEngineApp/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/Sample/LeanEngineApp/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/Sample/LeanEngineApp/appsettings.json b/Sample/LeanEngineApp/appsettings.json new file mode 100644 index 0000000..d9d9a9b --- /dev/null +++ b/Sample/LeanEngineApp/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +}