Files
UnrealEngineUWP/Engine/Source/Programs/Horde/HordeServer/Utilities/CollectionExtensions.cs
Ben Marsh 5abbc95b6e Add missing copyright notices.
[CL 16160939 by Ben Marsh in ue5-main branch]
2021-04-29 15:35:57 -04:00

34 lines
1009 B
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.IdentityModel.Tokens;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace HordeServer.Utilities
{
/// <summary>
/// Extension methods for collections
/// </summary>
public static class CollectionExtensions
{
/// <summary>
/// Adds an arbitrary sequence of items to a protobuf map field
/// </summary>
/// <typeparam name="TKey">The key type</typeparam>
/// <typeparam name="TValue">The value type</typeparam>
/// <param name="Map">The map to update</param>
/// <param name="Sequence">Sequence of items to add</param>
public static void Add<TKey, TValue>(this Google.Protobuf.Collections.MapField<TKey, TValue> Map, IEnumerable<KeyValuePair<TKey, TValue>> Sequence)
{
foreach(KeyValuePair<TKey, TValue> Pair in Sequence)
{
Map.Add(Pair.Key, Pair.Value);
}
}
}
}