protected override bool Equals(KeyBase other)
        {
            GuidKey key;

            if (!TryConvert(other, out key))
            {
                return(false);
            }

            return(Guid == key.Guid);
        }
        protected override int CompareValueTo(KeyBase other)
        {
            GuidKey key;

            if (!TryConvert(other, out key))
            {
                return(1);
            }

            return(Guid.CompareTo(key.Guid));
        }
Exemple #3
0
        protected override bool Equals(KeyBase other)
        {
            Int32Key key;

            if (!TryConvert(other, out key))
            {
                return(false);
            }

            return(ID == key.ID);
        }
Exemple #4
0
        protected override int CompareValueTo(KeyBase other)
        {
            Int32Key key;

            if (!TryConvert(other, out key))
            {
                return(1);
            }

            return(ID.CompareTo(key.ID));
        }
Exemple #5
0
        /// <summary>
        /// Tries to cast <paramref name="other"/> to <typeparamref name="T"/> or convert it using <see cref="Converts"/>.
        /// </summary>
        /// <typeparam name="T">The type of the target key.</typeparam>
        /// <param name="other">The key to convert.</param>
        /// <param name="key">The converter key.</param>
        /// <returns><c>true</c> if conversion was successful and <paramref name="key"/> is set; otherwise <c>false</c> and <paramref name="key"/> is <c>null</c>.</returns>
        protected bool TryConvert <T>(KeyBase other, out T key)
            where T : KeyBase
        {
            key = other as T;
            if (other == null && !Converts.Try <IKey, T>(other, out key))
            {
                return(false);
            }

            return(true);
        }
        protected override int CompareValueTo(KeyBase other)
        {
            StringKey key;

            if (!TryConvert(other, out key))
            {
                return(1);
            }

            return(Identifier.CompareTo(key.Identifier));
        }
        protected override bool Equals(KeyBase other)
        {
            StringKey key;

            if (!TryConvert(other, out key))
            {
                return(false);
            }

            return(Identifier == key.Identifier);
        }
Exemple #8
0
        public int CompareTo(object obj)
        {
            KeyBase key = obj as KeyBase;

            if (key == null)
            {
                return(1);
            }

            int typeCompare = Type.CompareTo(key.Type);

            if (typeCompare == 0)
            {
                return(CompareValueTo(key));
            }

            return(typeCompare);
        }
Exemple #9
0
        public bool Equals(IKey other)
        {
            KeyBase key = other as KeyBase;

            if (key == null)
            {
                return(false);
            }

            if (IsEmpty != key.IsEmpty)
            {
                return(false);
            }

            if (Type != key.Type)
            {
                return(false);
            }

            return(Equals(key));
        }
Exemple #10
0
 /// <summary>
 /// Should compare value of the <paramref name="other"/>.
 /// </summary>
 /// <param name="other">The other key to compare its value to.</param>
 /// <rereturns><see cref="IComparable.CompareTo"/>.</rereturns>
 protected abstract int CompareValueTo(KeyBase other);
Exemple #11
0
 /// <summary>
 /// Should compare this key value to value of <paramref name="other"/> and returns its values are equal.
 /// </summary>
 /// <param name="other">The other key to compare its value.</param>
 /// <returns></returns>
 protected abstract bool Equals(KeyBase other);