Exemplo n.º 1
0
        FastComparer(Type type)
        {
            Type = type;
            var comparerType = typeof(Comparer <>).MakeGenericType(type);

            comparer = comparerType.GetRuntimeProperty(nameof(Comparer <object> .Default)).GetValue(null);
            compare  = new FastMethodInfo(comparerType.GetRuntimeMethod(nameof(Comparer <object> .Compare), new Type[] { type }));
        }
Exemplo n.º 2
0
        FastEqualityComparer(Type type)
        {
            Type = type;
            var equalityComparerType = typeof(EqualityComparer <>).MakeGenericType(type);

            equalityComparer = equalityComparerType.GetRuntimeProperty(nameof(EqualityComparer <object> .Default)).GetValue(null);
            equals           = new FastMethodInfo(equalityComparerType.GetRuntimeMethod(nameof(EqualityComparer <object> .Equals), new Type[] { type, type }));
            getHashCode      = new FastMethodInfo(equalityComparerType.GetRuntimeMethod(nameof(EqualityComparer <object> .GetHashCode), new Type[] { type }));
        }