Пример #1
0
        private static EqualityComparer <T> CreateDefaultComparer()
        {
            if (typeof(T) == typeof(String))
            {
                return((EqualityComparer <T>)Intrinsics.UnsafeTypeConvert(new StringsEqualityComparer()));
            }

            if (typeof(T) == typeof(Int32))
            {
                return((EqualityComparer <T>)Intrinsics.UnsafeTypeConvert(new Int32EqualityComparer()));
            }

            if (typeof(T) == typeof(Byte))
            {
                return((EqualityComparer <T>)Intrinsics.UnsafeTypeConvert(new ByteEqualityComparer()));
            }

            if (typeof(T) == typeof(Int16))
            {
                return((EqualityComparer <T>)Intrinsics.UnsafeTypeConvert(new Int16EqualityComparer()));
            }

            if (typeof(T) == typeof(Int64))
            {
                return((EqualityComparer <T>)Intrinsics.UnsafeTypeConvert(new Int64EqualityComparer()));
            }

            if (typeof(T) == typeof(SByte))
            {
                return((EqualityComparer <T>)Intrinsics.UnsafeTypeConvert(new SByteEqualityComparer()));
            }

            if (typeof(T) == typeof(UInt16))
            {
                return((EqualityComparer <T>)Intrinsics.UnsafeTypeConvert(new UInt16EqualityComparer()));
            }

            if (typeof(T) == typeof(UInt32))
            {
                return((EqualityComparer <T>)Intrinsics.UnsafeTypeConvert(new UInt32EqualityComparer()));
            }

            if (typeof(T) == typeof(UInt64))
            {
                return((EqualityComparer <T>)Intrinsics.UnsafeTypeConvert(new UInt64EqualityComparer()));
            }

            return(new DefaultEqualityComparer <T>());
        }