Browse Source

Apewer-6.0.13:提升兼容性。

dev
Elivo 5 years ago
parent
commit
f08059c66e
  1. 2
      Apewer/Apewer.csproj
  2. 12
      Apewer/Internals/TextConverter.cs
  3. 6
      Apewer/Web/ApiInternals.cs
  4. 15
      Apewer/Web/ApiInvoker.cs
  5. 4
      Apewer/_ChangeLog.md

2
Apewer/Apewer.csproj

@ -7,7 +7,7 @@
<AssemblyName>Apewer</AssemblyName> <AssemblyName>Apewer</AssemblyName>
<PackageId>Apewer</PackageId> <PackageId>Apewer</PackageId>
<Title>Apewer</Title> <Title>Apewer</Title>
<Version>6.0.12</Version> <Version>6.0.13</Version>
</PropertyGroup> </PropertyGroup>
<!-- Info --> <!-- Info -->

12
Apewer/Internals/TextConverter.cs

@ -243,6 +243,9 @@ namespace Apewer.Internals
try try
{ {
var t = text.Trim(); var t = text.Trim();
t = t.Replace(" ", "").Replace(",", "").Replace(",", "");
t = t.Replace("。", ".");
var p = 0; var p = 0;
while (t.Length > 0 && t.EndsWith("%")) while (t.Length > 0 && t.EndsWith("%"))
{ {
@ -267,6 +270,9 @@ namespace Apewer.Internals
try try
{ {
var t = text.Trim(); var t = text.Trim();
t = t.Replace(" ", "").Replace(",", "").Replace(",", "");
t = t.Replace("。", ".");
var p = 0; var p = 0;
while (t.Length > 0 && t.EndsWith("%")) while (t.Length > 0 && t.EndsWith("%"))
{ {
@ -291,6 +297,9 @@ namespace Apewer.Internals
try try
{ {
var t = text.Trim(); var t = text.Trim();
t = t.Replace(" ", "").Replace(",", "").Replace(",", "");
t = t.Replace("。", ".");
var p = 0; var p = 0;
while (t.Length > 0 && t.EndsWith("%")) while (t.Length > 0 && t.EndsWith("%"))
{ {
@ -306,6 +315,9 @@ namespace Apewer.Internals
try try
{ {
var t = text.Trim(); var t = text.Trim();
t = t.Replace(" ", "").Replace(",", "").Replace(",", "");
t = t.Replace("。", ".");
var p = 0; var p = 0;
while (t.Length > 0 && t.EndsWith("%")) while (t.Length > 0 && t.EndsWith("%"))
{ {

6
Apewer/Web/ApiInternals.cs

@ -34,7 +34,7 @@ namespace Apewer.Web
public static List<Assembly> Assemblies { get { return _assemblies; } set { _assemblies = value; } } public static List<Assembly> Assemblies { get { return _assemblies; } set { _assemblies = value; } }
internal static Dictionary<string, ApiApplication> GetEntries(IEnumerable<Assembly> assemblies, bool sort = false) internal static Dictionary<string, ApiApplication> GetEntries(IEnumerable<Assembly> assemblies, bool sort = true)
{ {
var entries = new Dictionary<string, ApiApplication>(); var entries = new Dictionary<string, ApiApplication>();
@ -67,14 +67,14 @@ namespace Apewer.Web
var fns = new List<string>(); var fns = new List<string>();
fns.AddRange(ClassUtility.GetOrigin(fes).Keys); fns.AddRange(ClassUtility.GetOrigin(fes).Keys);
if (sort) fns = SortUtility.Ascend(fns); if (sort) fns.Sort();
foreach (var i in fns) application.Functions.Add(i, fes[i]); foreach (var i in fns) application.Functions.Add(i, fes[i]);
} }
} }
var ans = new List<string>(); var ans = new List<string>();
ans.AddRange(ClassUtility.GetOrigin(aes).Keys); ans.AddRange(ClassUtility.GetOrigin(aes).Keys);
if (sort) ans = SortUtility.Ascend(ans); if (sort) ans.Sort();
foreach (var i in ans) entries.Add(i, aes[i]); foreach (var i in ans) entries.Add(i, aes[i]);
return entries; return entries;

15
Apewer/Web/ApiInvoker.cs

@ -458,12 +458,20 @@ namespace Apewer.Web
/// <summary>设置 Kestrel 的 API 入口。</summary> /// <summary>设置 Kestrel 的 API 入口。</summary>
/// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentNullException"></exception>
public static void SetKestrelEntries(IEnumerable<Assembly> assemblies, bool sort = false) public static void SetKestrelEntries(IEnumerable<Assembly> assemblies, bool sort = true)
{ {
if (assemblies == null) throw new ArgumentNullException(nameof(assemblies)); if (assemblies == null) throw new ArgumentNullException(nameof(assemblies));
KestrelEntries = ApiInternals.GetEntries(assemblies, sort); KestrelEntries = ApiInternals.GetEntries(assemblies, sort);
} }
/// <summary>设置 Kestrel 的 API 入口。</summary>
public static void SetKestrelEntries(Assembly assembly, bool sort = true)
{
var assemblies = new Assembly[] { assembly };
if (assemblies[0] == null) assemblies[0] = Assembly.GetCallingAssembly();
KestrelEntries = ApiInternals.GetEntries(assemblies, sort);
}
// internal static async Task Execute(HttpContext context) // internal static async Task Execute(HttpContext context)
// { // {
// Invoke(context, ApiInternals.Entries); // Invoke(context, ApiInternals.Entries);
@ -479,11 +487,10 @@ namespace Apewer.Web
} }
/// <summary>运行 Kestrel 服务器,可指定端口和最大请求 Body 长度。默认同步运行,阻塞当前线程。</summary> /// <summary>运行 Kestrel 服务器,可指定端口和最大请求 Body 长度。默认同步运行,阻塞当前线程。</summary>
/// <remarks>注意:启动前必须设置 Kestrel Entries。</remarks> /// <remarks>注意:启动前应使用 SetKestrelEntries 方法设置 Kestrel Entries。</remarks>
/// <exception cref="MissingMemberException"></exception>
public static IHost RunKestrel(int port = 80, int request = 1073741824, bool async = false) public static IHost RunKestrel(int port = 80, int request = 1073741824, bool async = false)
{ {
if (KestrelEntries == null) throw new MissingMemberException(); if (KestrelEntries == null) SetKestrelEntries(Assembly.GetCallingAssembly());
var builder1 = Host.CreateDefaultBuilder(); var builder1 = Host.CreateDefaultBuilder();
var builder2 = builder1.ConfigureWebHostDefaults((builder3) => var builder2 = builder1.ConfigureWebHostDefaults((builder3) =>

4
Apewer/_ChangeLog.md

@ -5,6 +5,10 @@
### 最新提交 ### 最新提交
### 6.0.13
- 从文本转换到 Single、Double 和 Decimal,在转换前将自动修剪;
- 不再强制要求在启动 Kestrel 前调用 SetKestrelEntries。
### 6.0.12 ### 6.0.12
- 扩展方法 ToSingle、ToDouble、ToDecimal 支持输入百分号。 - 扩展方法 ToSingle、ToDouble、ToDecimal 支持输入百分号。

Loading…
Cancel
Save