示例#1
0
        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));
        }
示例#2
0
        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);
        }
示例#3
0
        public ValueParser(Func <string, T> parseFunction, Func <T, string> formatFunction)
        {
            parseFunction.ThrowIfNullArgument(nameof(parseFunction));
            formatFunction.ThrowIfNullArgument(nameof(formatFunction));

            this.parseFunction  = parseFunction;
            this.formatFunction = formatFunction;
        }
示例#4
0
 public static TResult Map <T, TResult>(this T source, Func <T, TResult> mapFunc)
 {
     source.ThrowIfNullArgument(nameof(source));
     mapFunc.ThrowIfNullArgument(nameof(mapFunc));
     return(mapFunc(source));
 }
示例#5
0
 public FilterTypes(EFilterMode mode, Func<Type, bool> filter)
 {
     _mode = mode;
     _filter = filter.ThrowIfNullArgument("filter");
 }