Delete runtime projection helper remnants
This commit is contained in:
parent
6c75edc4f5
commit
63c396be42
7 changed files with 111 additions and 127 deletions
54
Assets/Scripts/ServerShared/EnumerableSelectionExtensions.cs
Normal file
54
Assets/Scripts/ServerShared/EnumerableSelectionExtensions.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public static class EnumerableSelectionExtensions
|
||||
{
|
||||
public static T MaxBy<T, U>(this IEnumerable<T> items, Func<T, U> selector)
|
||||
{
|
||||
if (!items.Any())
|
||||
{
|
||||
throw new InvalidOperationException("Empty input sequence");
|
||||
}
|
||||
|
||||
var comparer = Comparer<U>.Default;
|
||||
var maxItem = items.First();
|
||||
var maxValue = selector(maxItem);
|
||||
|
||||
foreach (var item in items.Skip(1))
|
||||
{
|
||||
var value = selector(item);
|
||||
if (comparer.Compare(value, maxValue) > 0)
|
||||
{
|
||||
maxValue = value;
|
||||
maxItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
return maxItem;
|
||||
}
|
||||
|
||||
public static T MinBy<T, U>(this IEnumerable<T> items, Func<T, U> selector)
|
||||
{
|
||||
if (!items.Any())
|
||||
{
|
||||
throw new InvalidOperationException("Empty input sequence");
|
||||
}
|
||||
|
||||
var comparer = Comparer<U>.Default;
|
||||
var minItem = items.First();
|
||||
var minValue = selector(minItem);
|
||||
|
||||
foreach (var item in items.Skip(1))
|
||||
{
|
||||
var value = selector(item);
|
||||
if (comparer.Compare(value, minValue) < 0)
|
||||
{
|
||||
minValue = value;
|
||||
minItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
return minItem;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: eed05df00a9a6b84292c81be1662a66e
|
||||
guid: 7b36e5ee07ee44d68e755ea4993d9dd6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public static class CollectionExtensions
|
||||
{
|
||||
// https://stackoverflow.com/a/3188835
|
||||
public static T MaxBy<T, U>(this IEnumerable<T> items, Func<T, U> selector)
|
||||
{
|
||||
if (!items.Any())
|
||||
{
|
||||
throw new InvalidOperationException("Empty input sequence");
|
||||
}
|
||||
|
||||
var comparer = Comparer<U>.Default;
|
||||
T maxItem = items.First();
|
||||
U maxValue = selector(maxItem);
|
||||
|
||||
foreach (T item in items.Skip(1))
|
||||
{
|
||||
// Get the value of the item and compare it to the current max.
|
||||
U value = selector(item);
|
||||
if (comparer.Compare(value, maxValue) > 0)
|
||||
{
|
||||
maxValue = value;
|
||||
maxItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
return maxItem;
|
||||
}
|
||||
|
||||
public static T MinBy<T, U>(this IEnumerable<T> items, Func<T, U> selector)
|
||||
{
|
||||
if (!items.Any())
|
||||
{
|
||||
throw new InvalidOperationException("Empty input sequence");
|
||||
}
|
||||
|
||||
var comparer = Comparer<U>.Default;
|
||||
T maxItem = items.First();
|
||||
U maxValue = selector(maxItem);
|
||||
|
||||
foreach (T item in items.Skip(1))
|
||||
{
|
||||
// Get the value of the item and compare it to the current max.
|
||||
U value = selector(item);
|
||||
if (comparer.Compare(value, maxValue) < 0)
|
||||
{
|
||||
maxValue = value;
|
||||
maxItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
return maxItem;
|
||||
}
|
||||
}
|
||||
|
||||
public static class AsyncAwaitExtensions
|
||||
{
|
||||
public static async void WrapAwait(this Task task)
|
||||
{
|
||||
await task;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public static class ReflectionExtensions
|
||||
{
|
||||
public static string SplitCamelCase( this string str )
|
||||
{
|
||||
return Regex.Replace(
|
||||
Regex.Replace(
|
||||
str,
|
||||
@"(\P{Ll})(\P{Ll}\p{Ll})",
|
||||
"$1 $2"
|
||||
),
|
||||
@"(\p{Ll})(\P{Ll})",
|
||||
"$1 $2"
|
||||
);
|
||||
}
|
||||
|
||||
public static string FormatTypeName(this string typeName)
|
||||
{
|
||||
return (typeName.EndsWith("Data", StringComparison.InvariantCultureIgnoreCase)
|
||||
? typeName.Substring(0, typeName.Length - 4)
|
||||
: typeName).SplitCamelCase();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fd5642f26b80465fb57f3d2610633140
|
||||
timeCreated: 1617055075
|
||||
Loading…
Reference in a new issue