继续重构调整(UI)

- 引入 UniTask 和异步版本的 UIModule
- 调整 Runtime/UIBase 和 Presentation 下的脚本命名空间到 SepCore.UI
- 将原来的 5 层 UI 迁移到异步实现
- 规范各层的 UI 脚本命名
This commit is contained in:
SepComet
2026-06-03 09:58:37 +08:00
parent 6b8a6a8789
commit 7bba8bbb80
552 changed files with 83648 additions and 2726 deletions
@@ -0,0 +1,58 @@
using Cysharp.Threading.Tasks.Internal;
using System;
using System.Threading;
namespace Cysharp.Threading.Tasks.Linq
{
public static partial class UniTaskAsyncEnumerable
{
public static UniTask<TSource> ElementAtAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, int index, CancellationToken cancellationToken = default)
{
Error.ThrowArgumentNullException(source, nameof(source));
return ElementAt.ElementAtAsync(source, index, cancellationToken, false);
}
public static UniTask<TSource> ElementAtOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, int index, CancellationToken cancellationToken = default)
{
Error.ThrowArgumentNullException(source, nameof(source));
return ElementAt.ElementAtAsync(source, index, cancellationToken, true);
}
}
internal static class ElementAt
{
public static async UniTask<TSource> ElementAtAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, int index, CancellationToken cancellationToken, bool defaultIfEmpty)
{
var e = source.GetAsyncEnumerator(cancellationToken);
try
{
int i = 0;
while (await e.MoveNextAsync())
{
if (i++ == index)
{
return e.Current;
}
}
if (defaultIfEmpty)
{
return default;
}
else
{
throw Error.ArgumentOutOfRange(nameof(index));
}
}
finally
{
if (e != null)
{
await e.DisposeAsync();
}
}
}
}
}