Skip to content

Commit

Permalink
😊 添加全新的流变对象(粘土对象)代码
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkSoul committed Dec 29, 2024
1 parent 8ba341a commit a1d6c3c
Show file tree
Hide file tree
Showing 18 changed files with 3,316 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ internal static (Func<object, object?> KeyGetter, Func<object, object?> ValueGet
// 空检查
if (type is null)
{
return default;
return null;
}

// 检查是否是泛型类型
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// ------------------------------------------------------------------------
// 版权信息
// 版权归百小僧及百签科技(广东)有限公司所有。
// 所有权利保留。
// 官方网站:https://baiqian.com
//
// 许可证信息
// Furion 项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// 官方网站:https://furion.net
//
// 使用条款
// 使用本代码应遵守相关法律法规和许可证的要求。
//
// 免责声明
// 对于因使用本代码而产生的任何直接、间接、偶然、特殊或后果性损害,我们不承担任何责任。
//
// 其他重要信息
// Furion 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。
// 有关 Furion 项目的其他详细信息,请参阅位于源代码树根目录中的 COPYRIGHT 和 DISCLAIMER 文件。
//
// 更多信息
// 请访问 https://gitee.com/dotnetchina/Furion 获取更多关于 Furion 项目的许可证和版权信息。
// ------------------------------------------------------------------------

using System.Text.Json;

namespace Furion.Extensions;

/// <summary>
/// <see cref="Utf8JsonReader" /> 拓展类
/// </summary>
internal static class Utf8JsonReaderExtensions
{
/// <summary>
/// 获取 JSON 原始输入数据
/// </summary>
/// <param name="reader">
/// <see cref="Utf8JsonReader" />
/// </param>
/// <returns>
/// <see cref="string" />
/// </returns>
internal static string GetRawText(this ref Utf8JsonReader reader)
{
// 将 Utf8JsonReader 转换为 JsonDocument
using var jsonDocument = JsonDocument.ParseValue(ref reader);

return jsonDocument.RootElement.Clone().GetRawText();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ------------------------------------------------------------------------
// 版权信息
// 版权归百小僧及百签科技(广东)有限公司所有。
// 所有权利保留。
// 官方网站:https://baiqian.com
//
// 许可证信息
// Furion 项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// 官方网站:https://furion.net
//
// 使用条款
// 使用本代码应遵守相关法律法规和许可证的要求。
//
// 免责声明
// 对于因使用本代码而产生的任何直接、间接、偶然、特殊或后果性损害,我们不承担任何责任。
//
// 其他重要信息
// Furion 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。
// 有关 Furion 项目的其他详细信息,请参阅位于源代码树根目录中的 COPYRIGHT 和 DISCLAIMER 文件。
//
// 更多信息
// 请访问 https://gitee.com/dotnetchina/Furion 获取更多关于 Furion 项目的许可证和版权信息。
// ------------------------------------------------------------------------

namespace Furion.Shapeless;

/// <summary>
/// 流变对象的基本类型
/// </summary>
/// <remarks>用于区分是单一对象还是集合(数组)形式。</remarks>
public enum ClayType
{
/// <summary>
/// 单一对象
/// </summary>
/// <remarks>缺省值。</remarks>
Object = 0,

/// <summary>
/// 集合(数组)形式
/// </summary>
Array
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// ------------------------------------------------------------------------
// 版权信息
// 版权归百小僧及百签科技(广东)有限公司所有。
// 所有权利保留。
// 官方网站:https://baiqian.com
//
// 许可证信息
// Furion 项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// 官方网站:https://furion.net
//
// 使用条款
// 使用本代码应遵守相关法律法规和许可证的要求。
//
// 免责声明
// 对于因使用本代码而产生的任何直接、间接、偶然、特殊或后果性损害,我们不承担任何责任。
//
// 其他重要信息
// Furion 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。
// 有关 Furion 项目的其他详细信息,请参阅位于源代码树根目录中的 COPYRIGHT 和 DISCLAIMER 文件。
//
// 更多信息
// 请访问 https://gitee.com/dotnetchina/Furion 获取更多关于 Furion 项目的许可证和版权信息。
// ------------------------------------------------------------------------

using System.Text.Json;
using System.Text.Json.Serialization;

namespace Furion.Shapeless;

/// <summary>
/// <see cref="Clay" /> JSON 序列化转换器
/// </summary>
public sealed class ClayJsonConverter : JsonConverter<Clay>
{
/// <inheritdoc />
public override Clay? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
Clay.Parse(ref reader, new ClayOptions { JsonSerializerOptions = options });

/// <inheritdoc />
public override void Write(Utf8JsonWriter writer, Clay value, JsonSerializerOptions options) =>
writer.WriteRawValue(value.ToJsonString(options));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// ------------------------------------------------------------------------
// 版权信息
// 版权归百小僧及百签科技(广东)有限公司所有。
// 所有权利保留。
// 官方网站:https://baiqian.com
//
// 许可证信息
// Furion 项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// 官方网站:https://furion.net
//
// 使用条款
// 使用本代码应遵守相关法律法规和许可证的要求。
//
// 免责声明
// 对于因使用本代码而产生的任何直接、间接、偶然、特殊或后果性损害,我们不承担任何责任。
//
// 其他重要信息
// Furion 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。
// 有关 Furion 项目的其他详细信息,请参阅位于源代码树根目录中的 COPYRIGHT 和 DISCLAIMER 文件。
//
// 更多信息
// 请访问 https://gitee.com/dotnetchina/Furion 获取更多关于 Furion 项目的许可证和版权信息。
// ------------------------------------------------------------------------

using System.Text;

namespace Furion.Shapeless;

/// <summary>
/// <c>UTF-8</c> 格式的 <see cref="StringWriter" />
/// </summary>
internal sealed class Utf8StringWriter : StringWriter
{
/// <inheritdoc />
public override Encoding Encoding => Encoding.UTF8;
}
Loading

0 comments on commit a1d6c3c

Please sign in to comment.