mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 04:13:40 +01:00
merge master into profiles
This commit is contained in:
commit
fe6196d0ad
57 changed files with 1118 additions and 287 deletions
|
|
@ -17,6 +17,7 @@ using Dalamud.Game.ClientState.Objects.Types;
|
|||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Logging.Internal;
|
||||
using Dalamud.Networking.Http;
|
||||
using ImGuiNET;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using Microsoft.Win32;
|
||||
|
|
@ -40,7 +41,8 @@ public static class Util
|
|||
/// Gets an httpclient for usage.
|
||||
/// Do NOT await this.
|
||||
/// </summary>
|
||||
public static HttpClient HttpClient { get; } = new();
|
||||
[Obsolete($"Use Service<{nameof(HappyHttpClient)}> instead.")]
|
||||
public static HttpClient HttpClient { get; } = Service<HappyHttpClient>.Get().SharedHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the assembly version of Dalamud.
|
||||
|
|
@ -556,6 +558,56 @@ public static class Util
|
|||
Process.Start(process);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform a "zipper merge" (A, 1, B, 2, C, 3) of multiple enumerables, allowing for lists to end early.
|
||||
/// </summary>
|
||||
/// <param name="sources">A set of enumerable sources to combine.</param>
|
||||
/// <typeparam name="TSource">The resulting type of the merged list to return.</typeparam>
|
||||
/// <returns>A new enumerable, consisting of the final merge of all lists.</returns>
|
||||
public static IEnumerable<TSource> ZipperMerge<TSource>(params IEnumerable<TSource>[] sources)
|
||||
{
|
||||
// Borrowed from https://codereview.stackexchange.com/a/263451, thank you!
|
||||
var enumerators = new IEnumerator<TSource>[sources.Length];
|
||||
try
|
||||
{
|
||||
for (var i = 0; i < sources.Length; i++)
|
||||
{
|
||||
enumerators[i] = sources[i].GetEnumerator();
|
||||
}
|
||||
|
||||
var hasNext = new bool[enumerators.Length];
|
||||
|
||||
bool MoveNext()
|
||||
{
|
||||
var anyHasNext = false;
|
||||
for (var i = 0; i < enumerators.Length; i++)
|
||||
{
|
||||
anyHasNext |= hasNext[i] = enumerators[i].MoveNext();
|
||||
}
|
||||
|
||||
return anyHasNext;
|
||||
}
|
||||
|
||||
while (MoveNext())
|
||||
{
|
||||
for (var i = 0; i < enumerators.Length; i++)
|
||||
{
|
||||
if (hasNext[i])
|
||||
{
|
||||
yield return enumerators[i].Current;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
foreach (var enumerator in enumerators)
|
||||
{
|
||||
enumerator?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose this object.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue