mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-24 20:34:29 +08:00
refactor(pipe): 移除Apply和On扩展方法
- 删除了Apply扩展方法及其相关文档注释 - 删除了On扩展方法及其相关文档注释 - 移除了对应的单元测试方法 - 保留了Also、Pipe等其他管道操作方法
This commit is contained in:
parent
c9dd969b05
commit
20bbf2297e
@ -66,21 +66,6 @@ public class PipeExtensionsTests
|
|||||||
int AddTwo(int x) => x + 2;
|
int AddTwo(int x) => x + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 测试Apply方法 - 验证函数能够正确应用到参数上
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void Apply_Should_Apply_Function_To_Argument()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
Func<int, int> multiplyByTwo = x => x * 2;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = multiplyByTwo.Apply(5);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.That(result, Is.EqualTo(10));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 测试Also方法 - 验证执行操作后返回原值功能
|
/// 测试Also方法 - 验证执行操作后返回原值功能
|
||||||
|
|||||||
@ -59,32 +59,6 @@ public static class PipeExtensions
|
|||||||
Func<TSource, TMiddle> first)
|
Func<TSource, TMiddle> first)
|
||||||
=> x => second(first(x));
|
=> x => second(first(x));
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Apply:将函数应用于值(柯里化辅助)
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TSource">输入值的类型</typeparam>
|
|
||||||
/// <typeparam name="TResult">函数返回结果的类型</typeparam>
|
|
||||||
/// <param name="func">要应用的函数</param>
|
|
||||||
/// <param name="value">要传递给函数的输入值</param>
|
|
||||||
/// <returns>函数执行后的结果</returns>
|
|
||||||
public static TResult Apply<TSource, TResult>(
|
|
||||||
this Func<TSource, TResult> func,
|
|
||||||
TSource value)
|
|
||||||
=> func(value);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// On:将值应用于函数(与Apply功能相同,但参数顺序相反)
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TSource">输入值的类型</typeparam>
|
|
||||||
/// <typeparam name="TResult">函数返回结果的类型</typeparam>
|
|
||||||
/// <param name="value">要传递给函数的输入值</param>
|
|
||||||
/// <param name="func">要应用的函数</param>
|
|
||||||
/// <returns>函数执行后的结果</returns>
|
|
||||||
public static TResult On<TSource, TResult>(
|
|
||||||
this TSource value,
|
|
||||||
Func<TSource, TResult> func)
|
|
||||||
=> func(value);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Also:执行操作并返回原值
|
/// Also:执行操作并返回原值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user