Exemplo n.º 1
0
 private static EqualityComparer <T> Create()
 {
     // The compiler will overwrite the Create method with optimized
     // instantiation-specific implementation.
     // This body serves as a fallback when instantiation-specific implementation is unavailable.
     return(_default = EqualityComparerHelpers.GetUnknownEquatableComparer <T>());
 }
Exemplo n.º 2
0
        private static EqualityComparer <T> Create()
        {
#if PROJECTN
            // The compiler will overwrite the Create method with optimized
            // instantiation-specific implementation.
            throw new NotSupportedException();
#else
            // The compiler will overwrite the Create method with optimized
            // instantiation-specific implementation.
            // This body serves as a fallback when instantiation-specific implementation is unavailable.
            return(_default = EqualityComparerHelpers.GetUnknownEquatableComparer <T>());
#endif
        }
Exemplo n.º 3
0
 private static EqualityComparer <T> Create()
 {
     // The compiler will overwrite the Create method with optimized
     // instantiation-specific implementation.
     // This body serves as a fallback when instantiation-specific implementation is unavailable.
     // If that happens, the compiler ensures we generate data structures to make the fallback work
     // when this method is compiled.
     Interlocked.CompareExchange(ref s_default,
                                 SupportsGenericIEquatableInterfaces
         ? Unsafe.As <EqualityComparer <T> >(EqualityComparerHelpers.GetComparer(typeof(T).TypeHandle))
         : new ObjectEqualityComparer <T>(),
                                 null);
     return(s_default);
 }
Exemplo n.º 4
0
 public sealed override bool Equals(T x, T y)
 {
     return(EqualityComparerHelpers.EnumOnlyEquals(x, y));
 }
 /// <summary>
 /// Gets the default equality comparer for this type.
 /// </summary>
 public static IFullEqualityComparer <T> Default <T>(this EqualityComparerBuilderFor <T> @this) => (IFullEqualityComparer <T>)EqualityComparerHelpers.NormalizeDefault <T>(null);
Exemplo n.º 6
0
 private static EqualityComparer <T> Create()
 {
     // The compiler will overwrite the Create method with optimized
     // instantiation-specific implementation.
     // This body serves as a fallback when instantiation-specific implementation is unavailable.
     Interlocked.CompareExchange(ref s_default, Unsafe.As <EqualityComparer <T> >(EqualityComparerHelpers.GetComparer(typeof(T).TypeHandle)), null);
     return(s_default);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Gets the default equality comparer for this type.
 /// </summary>
 public IFullEqualityComparer <T> Default()
 {
     return((IFullEqualityComparer <T>)EqualityComparerHelpers.NormalizeDefault <T>(null));
 }
 /// <summary>
 /// Gets the default equality comparer for this type.
 /// </summary>
 public static IEqualityComparer <T> Default()
 {
     Contract.Ensures(Contract.Result <IEqualityComparer <T> >() != null);
     return(EqualityComparerHelpers.NormalizeDefault <T>((IEqualityComparer <T>)null));
 }