Browse Source

Apewer-6.3.1:支持 Controller 指定当前 Response 的缩进。

dev
Elivo 4 years ago
parent
commit
1c6664cd58
  1. 2
      Apewer/Apewer.csproj
  2. 12
      Apewer/Internals/AccessHelper.cs
  3. 16
      Apewer/Json.cs
  4. 1
      Apewer/Source/Access.cs
  5. 3
      Apewer/Web/ApiProcessor.cs
  6. 3
      Apewer/Web/ApiResponse.cs
  7. 4
      Apewer/_ChangeLog.md

2
Apewer/Apewer.csproj

@ -20,7 +20,7 @@
<Description></Description> <Description></Description>
<RootNamespace>Apewer</RootNamespace> <RootNamespace>Apewer</RootNamespace>
<Product>Apewer Libraries</Product> <Product>Apewer Libraries</Product>
<Version>6.3.0</Version> <Version>6.3.1</Version>
</PropertyGroup> </PropertyGroup>
<!-- NuGet --> <!-- NuGet -->

12
Apewer/Internals/AccessHelper.cs

@ -44,11 +44,15 @@ namespace Apewer.Internals
{ {
file.Position = 0L; file.Position = 0L;
file.Seek(0L, SeekOrigin.Begin); file.Seek(0L, SeekOrigin.Begin);
var password = func(file); try
{
var password = func(file);
if (string.IsNullOrEmpty(password)) return; if (string.IsNullOrEmpty(password)) return;
if (list.Contains(password)) return; if (list.Contains(password)) return;
list.Add(password); list.Add(password);
}
catch { }
} }
#region 方式 1 #region 方式 1

16
Apewer/Json.cs

@ -1430,26 +1430,18 @@ namespace Apewer
{ {
return json._jvalue.Value.ToString(); return json._jvalue.Value.ToString();
} }
return json._jtoken.ToString(indented ? Formatting.Indented : Formatting.None); return json._jtoken.ToString(indented ? Formatting.Indented : Formatting.None);
} }
/// <summary>从 Json 到 String 的隐式转换,默认不缩进。</summary> /// <summary>从 Json 到 String 的隐式转换,默认不缩进。</summary>
public static implicit operator string(Json json) public static implicit operator string(Json json) => Export(json, false);
{
return Export(json, false);
}
/// <summary>生成字符串,默认不缩进。若类型为 String,则导出 String 值。</summary> /// <summary>生成字符串,默认不缩进。若类型为 String,则导出 String 值。</summary>
public override string ToString() public override string ToString() => Export(this, false);
{
return Export(this, false);
}
/// <summary>生成字符串,可指定缩进。若类型为 String,则导出 String 值,忽略缩进。</summary> /// <summary>生成字符串,可指定缩进。若类型为 String,则导出 String 值,忽略缩进。</summary>
public string ToString(bool indented) public string ToString(bool indented) => Export(this, indented);
{
return Export(this, indented);
}
#endregion #endregion

1
Apewer/Source/Access.cs

@ -17,6 +17,7 @@ namespace Apewer.Source
{ {
/// <summary>尝试解析 Access 文件的密码。</summary> /// <summary>尝试解析 Access 文件的密码。</summary>
/// <remarks>当操作系统启用随机化内存分配时,此方法可能会产生异常。</remarks>
public static string[] ParsePassword(string path) => AccessHelper.GetPassword(path); public static string[] ParsePassword(string path) => AccessHelper.GetPassword(path);
} }

3
Apewer/Web/ApiProcessor.cs

@ -647,7 +647,8 @@ namespace Apewer.Web
// 用户数据。 // 用户数据。
json.SetProperty("data", response.Data); json.SetProperty("data", response.Data);
var text = json.ToString(ApiOptions.JsonIndent); var indented = ApiOptions.JsonIndent || response.Indented;
var text = json.ToString(indented);
return text; return text;
} }

3
Apewer/Web/ApiResponse.cs

@ -44,6 +44,9 @@ namespace Apewer.Web
/// <remarks>在 .NET Framework 中,此设置可能无效。</remarks> /// <remarks>在 .NET Framework 中,此设置可能无效。</remarks>
public int Expires { get; set; } public int Expires { get; set; }
/// <summary>当响应 Json 时,强制缩进排版。</summary>
public bool Indented { get; set; } = false;
/// <summary>自定义数据。</summary> /// <summary>自定义数据。</summary>
public Json Data public Json Data
{ {

4
Apewer/_ChangeLog.md

@ -1,6 +1,10 @@
 
### 最新提交 ### 最新提交
### 6.3.1
- Source:修正了多次获取 Access 密码会报错的问题;
- Web:对 ApiResponse 中增加 Indented,支持对单个 API 的响应强制缩进排版。
### 6.3.0 ### 6.3.0
- 调整变量命名方式,统一采用 Camel 风格; - 调整变量命名方式,统一采用 Camel 风格;
- 代码优化,删除 Internals 类,降低了栈空间的占用; - 代码优化,删除 Internals 类,降低了栈空间的占用;

Loading…
Cancel
Save