/// <summary> /// Method called by the finder to set up registrations before any comparer requests are handled. /// /// If you supply a custom configuration and want to apply the default registrations, add a call to base.RegisterComparers() from your method override. /// </summary> public virtual void RegisterComparers() { #region Basic types for platforms without JIT compilation if (NoJit) { // // Note: On non-JIT platforms, you must be careful to not get too cute / abstract with your registrations or the AOT may not create // all the necessary generic types and you'll end up with JIT exceptions. When in doubt, add each registration directly with a // individual method call the compiler can easily discover with static inspection, and if supplying your own comparer // implementation either inherit from the corresponding Smooth.Collections.Comparer or wrap your comparer in a FuncComparer to // force the compiler to create the proper types. // #region System built-in types Finder.RegisterIComparableIEquatable <Boolean>(); Finder.RegisterIComparableIEquatable <Char>(); Finder.RegisterIComparableIEquatable <Byte>(); Finder.RegisterIComparableIEquatable <SByte>(); Finder.RegisterIComparableIEquatable <Int16>(); Finder.RegisterIComparableIEquatable <UInt16>(); Finder.RegisterIComparableIEquatable <Int32>(); Finder.RegisterIComparableIEquatable <UInt32>(); Finder.RegisterIComparableIEquatable <Int64>(); Finder.RegisterIComparableIEquatable <UInt64>(); Finder.RegisterIComparableIEquatable <Single>(); Finder.RegisterIComparableIEquatable <Double>(); Finder.RegisterIComparableIEquatable <Decimal>(); #endregion #region System.Runtime handles Finder.Register <RuntimeTypeHandle>((a, b) => a.Equals(b)); Finder.Register <RuntimeFieldHandle>((a, b) => a == b); Finder.Register <RuntimeMethodHandle>((a, b) => a == b); #endregion #region Smooth enums Finder.RegisterEnum <ComparerType>(); Finder.RegisterEnum <EventType>(); #endregion } #endregion }
/// <summary> /// Method called by the finder to set up registrations before any comparer requests are handled. /// /// If you supply a custom configuration and want to apply the default registrations, add a call to base.RegisterComparers() from your method override. /// </summary> public virtual void RegisterComparers() { #region Common structs without type specific equality and/or hashcode methods Finder.Register <Color32>((a, b) => Color32ToInt(a) == Color32ToInt(b), Color32ToInt); #endregion #region Basic types for platforms without JIT compilation if (NoJit) { // // Note: On non-JIT platforms, you must be careful to not get too cute / abstract with your registrations or the AOT may not create // all the necessary generic types and you'll end up with JIT exceptions. When in doubt, add each registration directly with a // individual method call the compiler can easily discover with static inspection, and if supplying your own comparer // implementation either inherit from the corresponding Smooth.Collections.Comparer or wrap your comparer in a FuncComparer to // force the compiler to create the proper types. // #region System built-in types Finder.RegisterIComparableIEquatable <Boolean>(); Finder.RegisterIComparableIEquatable <Char>(); Finder.RegisterIComparableIEquatable <Byte>(); Finder.RegisterIComparableIEquatable <SByte>(); Finder.RegisterIComparableIEquatable <Int16>(); Finder.RegisterIComparableIEquatable <UInt16>(); Finder.RegisterIComparableIEquatable <Int32>(); Finder.RegisterIComparableIEquatable <UInt32>(); Finder.RegisterIComparableIEquatable <Int64>(); Finder.RegisterIComparableIEquatable <UInt64>(); Finder.RegisterIComparableIEquatable <Single>(); Finder.RegisterIComparableIEquatable <Double>(); Finder.RegisterIComparableIEquatable <Decimal>(); #endregion #region System.Runtime handles Finder.Register <RuntimeTypeHandle>((a, b) => a.Equals(b)); Finder.Register <RuntimeFieldHandle>((a, b) => a == b); Finder.Register <RuntimeMethodHandle>((a, b) => a == b); #endregion #region UnityEngine structs // // Note: UnityEngine structs do not adhere to the contract of equality. // // Thus they should not be used as Dictionary keys or in other use cases that rely on a correct equality implementation. // Finder.Register <Color>((a, b) => a == b); Finder.Register <Vector2>((a, b) => a == b); Finder.Register <Vector3>((a, b) => a == b); Finder.Register <Vector4>((a, b) => a == b); Finder.Register <Quaternion>((a, b) => a == b); #endregion #region UnityEngine enums Finder.RegisterEnum <AudioSpeakerMode>(); Finder.RegisterEnum <EventModifiers>(); Finder.RegisterEnum <UnityEngine.EventType>(); Finder.RegisterEnum <KeyCode>(); Finder.RegisterEnum <PrimitiveType>(); Finder.RegisterEnum <RuntimePlatform>(); #endregion #region Smooth enums Finder.RegisterEnum <BasePlatform>(); Finder.RegisterEnum <ComparerType>(); Finder.RegisterEnum <EventType>(); #endregion } #endregion }