chore: rename

oneRain 2021-03-18 14:58:22 +08:00
parent aad4e7cc47
commit 615f2aff9c
14 changed files with 229 additions and 5 deletions

View File

@ -2,8 +2,8 @@
namespace LeanCloud.Engine {
public enum LCEngineUserHookType {
SMS,
Email,
OnSMSVerified,
OnEmailVerified,
OnLogin
}

View File

@ -5,7 +5,7 @@ namespace LeanCloud.Engine {
public static object HandlePing() {
LCLogger.Debug("Ping ~~~");
return new Dictionary<string, string> {
{ "runtime", "dotnet" },
{ "runtime", "dotnet-3.1" },
{ "version", LCApplication.SDKVersion }
};
}

View File

@ -96,9 +96,9 @@ namespace LeanCloud.Engine {
.ToDictionary(mi => {
LCEngineUserHookAttribute attr = mi.GetCustomAttribute<LCEngineUserHookAttribute>();
switch (attr.HookType) {
case LCEngineUserHookType.SMS:
case LCEngineUserHookType.OnSMSVerified:
return OnSMSVerified;
case LCEngineUserHookType.Email:
case LCEngineUserHookType.OnEmailVerified:
return OnEmailVerified;
case LCEngineUserHookType.OnLogin:
return OnLogin;

View File

@ -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<string, List<string>> Get() {
List<string> functions = new List<string> {
};
return new Dictionary<string, List<string>> {
{ "result", functions }
};
}
public async Task<object> Post() {
return null;
}
}
}

View File

@ -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<PingController> logger;
public PingController(ILogger<PingController> logger) {
this.logger = logger;
}
[HttpGet]
public Dictionary<string, string> Get() {
Console.WriteLine("ping get to console");
logger.LogDebug("ping get to logger");
return new Dictionary<string, string> {
{ "runtime", "dotnet" },
{ "version", "1.0.0" }
};
}
}
}

View File

@ -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<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger) {
_logger = logger;
}
[HttpGet]
public IEnumerable<WeatherForecast> 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();
}
}
}

View File

@ -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;
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
namespace LeanEngineApp.LeanEngine {
public class LeanEngine {
private Dictionary<string, object> dict;
public LeanEngine() {
}
}
}

View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ReleaseVersion>0.6.4</ReleaseVersion>
</PropertyGroup>
<ItemGroup>
<Folder Include="LeanEngine\" />
</ItemGroup>
</Project>

View File

@ -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<Startup>();
});
}
}

View File

@ -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();
});
}
}
}

View File

@ -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; }
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}