Пример #1
0
        /// <summary>
        /// -99 = null input
        /// -1 = wrong type
        /// 0 = same type, wrong id
        /// 1 = same reference (same id, same type)
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(ILiveData other)
        {
            if (other != null)
            {
                try
                {
                    if (other.GetType() != GetType())
                    {
                        return(-1);
                    }

                    if (other.BirthMark.Equals(BirthMark))
                    {
                        return(1);
                    }

                    return(0);
                }
                catch (Exception ex)
                {
                    LoggingUtility.LogError(ex);
                }
            }

            return(-99);
        }
Пример #2
0
        /// <summary>
        /// Compares this object to another one to see if they are the same object
        /// </summary>
        /// <param name="other">the object to compare to</param>
        /// <returns>true if the same object</returns>
        public bool Equals(ILiveData other)
        {
            if (other != default(ILiveData))
            {
                try
                {
                    return(other.GetType() == GetType() && other.BirthMark.Equals(BirthMark));
                }
                catch (Exception ex)
                {
                    LoggingUtility.LogError(ex);
                }
            }

            return(false);
        }
Пример #3
0
 /// <summary>
 /// Get the hash code for comparison purposes
 /// </summary>
 /// <param name="obj">the thing to get the hashcode for</param>
 /// <returns>the hash code</returns>
 public int GetHashCode(ILiveData obj)
 {
     return(obj.GetType().GetHashCode() + obj.BirthMark.GetHashCode());
 }
Пример #4
0
 /// <summary>
 /// Make a new cache key using the object
 /// </summary>
 /// <param name="data">the object</param>
 public LiveCacheKey(ILiveData data)
 {
     ObjectType = data.GetType();
     BirthMark  = data.BirthMark;
 }