Skip to content

Commit

Permalink
😊 新增 新版本流变(粘土)对象 DeleteIsDefined 方法,兼容旧版本升级
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkSoul committed Jan 11, 2025
1 parent b2ea36d commit eea8ab0
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 4 deletions.
34 changes: 32 additions & 2 deletions framework/Furion.Pure/V5_Experience/Shapeless/Clay/Clay.Exports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public string ToString(string? format, IFormatProvider? formatProvider)
}

/// <summary>
/// 创建空对象类型的 <see cref="Clay" /> 实例
/// 创建空的单一对象
/// </summary>
/// <param name="options">
/// <see cref="ClayOptions" />
Expand All @@ -219,7 +219,7 @@ public string ToString(string? format, IFormatProvider? formatProvider)
public static Clay EmptyObject(ClayOptions? options = null) => new(options);

/// <summary>
/// 创建空数组类型的 <see cref="Clay" /> 实例
/// 创建空的集合/数组
/// </summary>
/// <param name="options">
/// <see cref="ClayOptions" />
Expand Down Expand Up @@ -309,6 +309,16 @@ public bool Contains(object keyOrIndex)
return false;
}

/// <summary>
/// 检查键或索引是否定义
/// </summary>
/// <remarks>兼容旧版本粘土对象。</remarks>
/// <param name="keyOrIndex">键或索引</param>
/// <returns>
/// <see cref="bool" />
/// </returns>
public bool IsDefined(object keyOrIndex) => Contains(keyOrIndex);

/// <summary>
/// 根据键或索引获取值
/// </summary>
Expand Down Expand Up @@ -407,6 +417,16 @@ public bool Add(object? value)
/// </returns>
public bool Remove(object keyOrIndex) => RemoveValue(keyOrIndex);

/// <summary>
/// 根据键或索引删除数据
/// </summary>
/// <remarks>兼容旧版本粘土对象。</remarks>
/// <param name="keyOrIndex">键或索引</param>
/// <returns>
/// <see cref="bool" />
/// </returns>
public bool Delete(object keyOrIndex) => Remove(keyOrIndex);

/// <summary>
/// 将 <see cref="Clay" /> 转换为目标类型
/// </summary>
Expand Down Expand Up @@ -620,6 +640,16 @@ public bool TryInsert(int index, object? value)
/// </returns>
public bool TryRemove(object keyOrIndex) => Contains(keyOrIndex) && RemoveValue(keyOrIndex);

/// <summary>
/// 尝试根据键或索引删除数据
/// </summary>
/// <remarks>兼容旧版本粘土对象。</remarks>
/// <param name="keyOrIndex">键或索引</param>
/// <returns>
/// <see cref="bool" />
/// </returns>
public bool TryDelete(object keyOrIndex) => TryRemove(keyOrIndex);

/// <summary>
/// 设置为只读模式
/// </summary>
Expand Down
34 changes: 32 additions & 2 deletions framework/Furion/V5_Experience/Shapeless/Clay/Clay.Exports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public string ToString(string? format, IFormatProvider? formatProvider)
}

/// <summary>
/// 创建空对象类型的 <see cref="Clay" /> 实例
/// 创建空的单一对象
/// </summary>
/// <param name="options">
/// <see cref="ClayOptions" />
Expand All @@ -219,7 +219,7 @@ public string ToString(string? format, IFormatProvider? formatProvider)
public static Clay EmptyObject(ClayOptions? options = null) => new(options);

/// <summary>
/// 创建空数组类型的 <see cref="Clay" /> 实例
/// 创建空的集合/数组
/// </summary>
/// <param name="options">
/// <see cref="ClayOptions" />
Expand Down Expand Up @@ -309,6 +309,16 @@ public bool Contains(object keyOrIndex)
return false;
}

/// <summary>
/// 检查键或索引是否定义
/// </summary>
/// <remarks>兼容旧版本粘土对象。</remarks>
/// <param name="keyOrIndex">键或索引</param>
/// <returns>
/// <see cref="bool" />
/// </returns>
public bool IsDefined(object keyOrIndex) => Contains(keyOrIndex);

/// <summary>
/// 根据键或索引获取值
/// </summary>
Expand Down Expand Up @@ -407,6 +417,16 @@ public bool Add(object? value)
/// </returns>
public bool Remove(object keyOrIndex) => RemoveValue(keyOrIndex);

/// <summary>
/// 根据键或索引删除数据
/// </summary>
/// <remarks>兼容旧版本粘土对象。</remarks>
/// <param name="keyOrIndex">键或索引</param>
/// <returns>
/// <see cref="bool" />
/// </returns>
public bool Delete(object keyOrIndex) => Remove(keyOrIndex);

/// <summary>
/// 将 <see cref="Clay" /> 转换为目标类型
/// </summary>
Expand Down Expand Up @@ -620,6 +640,16 @@ public bool TryInsert(int index, object? value)
/// </returns>
public bool TryRemove(object keyOrIndex) => Contains(keyOrIndex) && RemoveValue(keyOrIndex);

/// <summary>
/// 尝试根据键或索引删除数据
/// </summary>
/// <remarks>兼容旧版本粘土对象。</remarks>
/// <param name="keyOrIndex">键或索引</param>
/// <returns>
/// <see cref="bool" />
/// </returns>
public bool TryDelete(object keyOrIndex) => TryRemove(keyOrIndex);

/// <summary>
/// 设置为只读模式
/// </summary>
Expand Down

0 comments on commit eea8ab0

Please sign in to comment.