public virtual void AddParser <T>(Func <string, T> parse, Func <T, string> format) { parse.ThrowIfNullArgument(nameof(parse)); format.ThrowIfNullArgument(nameof(format)); AddParser(new ValueParser <T>(parse, format)); }
public static Tcollection MaxBy <Tcollection, Tcompare>(this IEnumerable <Tcollection> enumerable, Func <Tcollection, Tcompare> mapper) where Tcompare : IComparable <Tcompare> { enumerable.ThrowIfNullArgument(nameof(enumerable)); mapper.ThrowIfNullArgument(nameof(mapper)); IEnumerator <Tcollection> enumerator = enumerable.GetEnumerator(); if (!enumerator.MoveNext()) { throw new InvalidOperationException("Enumerable is empty!"); } Tcollection result = enumerator.Current; Tcompare resultValue = mapper(result); while (enumerator.MoveNext()) { Tcollection testResult = enumerator.Current; Tcompare testValue = mapper(testResult); if (testValue.CompareTo(resultValue) <= 0) { continue; } result = testResult; resultValue = testValue; } return(result); }
public ValueParser(Func <string, T> parseFunction, Func <T, string> formatFunction) { parseFunction.ThrowIfNullArgument(nameof(parseFunction)); formatFunction.ThrowIfNullArgument(nameof(formatFunction)); this.parseFunction = parseFunction; this.formatFunction = formatFunction; }
public static TResult Map <T, TResult>(this T source, Func <T, TResult> mapFunc) { source.ThrowIfNullArgument(nameof(source)); mapFunc.ThrowIfNullArgument(nameof(mapFunc)); return(mapFunc(source)); }
public FilterTypes(EFilterMode mode, Func<Type, bool> filter) { _mode = mode; _filter = filter.ThrowIfNullArgument("filter"); }