示例#1
0
        public void CompareTo_BCVRef()
        {
            ScrReference ref1 = new ScrReference("GEN 30:1", ScrVers.Original);
            BCVRef       ref2 = new BCVRef("GEN 30:1");

            Assert.AreEqual(0, ref1.CompareTo(ref2));
        }
示例#2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Compares the current instance with another object of the same type.
        /// </summary>
        /// <param name="obj">An object to compare with this instance.</param>
        /// <returns>
        /// A 32-bit signed integer that indicates the relative order of the objects being
        /// compared. The return value has these meanings:
        ///
        /// Value				Meaning
        /// Less than zero		This instance is less than <paramref name="obj"/>.
        /// Zero				This instance is equal to <paramref name="obj"/>.
        /// Greater than zero	This instance is greater than <paramref name="obj"/>.
        /// </returns>
        /// <exception cref="T:System.ArgumentException">
        ///     <paramref name="obj"/> is not the same type as this instance. </exception>
        /// ------------------------------------------------------------------------------------
        public override int CompareTo(object obj)
        {
            if (obj == null)
            {
                throw new ArgumentException();
            }

            ScrReference right;

            if (obj is ScrReference)
            {
                right = (ScrReference)obj;

                // If versifications don't match, make a new one, converted to correct versification
                if (m_versification != right.m_versification &&
                    m_versification != ScrVers.Unknown &&
                    right.m_versification != ScrVers.Unknown)
                {
                    // Neither of the versifications involved are unknown, so do a normal conversion
                    right = new ScrReference(right, m_versification);
                }
                else if (m_versification != right.m_versification)
                {
                    // one of the versifications involved is unknown, so just treat it as the same
                    // versification as the known one.
                    if (right.m_versification != ScrVers.Unknown)
                    {
                        ScrReference newThis = new ScrReference(BBCCCVVV, right.m_versification);
                        return(newThis.CompareTo(right));
                    }

                    right = new ScrReference(right.BBCCCVVV, m_versification);
                }
            }
            else if (obj is BCVRef)
            {
                right = new ScrReference((BCVRef)obj, m_versification);
            }
            else if (obj is int)
            {
                right = new ScrReference((int)obj, m_versification);
            }
            else
            {
                throw new ArgumentException();
            }

            return(base.CompareTo(right));
        }
		public void CompareTo_int()
		{
			ScrReference ref1 = new ScrReference("GEN 30:1", ScrVers.Original);
			Assert.AreEqual(0, ref1.CompareTo(1030001));
		}
		public void CompareTo_BCVRef()
		{
			ScrReference ref1 = new ScrReference("GEN 30:1", ScrVers.Original);
			BCVRef ref2 = new BCVRef("GEN 30:1");
			Assert.AreEqual(0, ref1.CompareTo(ref2));
		}
示例#5
0
        public void CompareTo_int()
        {
            ScrReference ref1 = new ScrReference("GEN 30:1", ScrVers.Original);

            Assert.AreEqual(0, ref1.CompareTo(1030001));
        }
示例#6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Compares the current instance with another object of the same type.
		/// </summary>
		/// <param name="obj">An object to compare with this instance.</param>
		/// <returns>
		/// A 32-bit signed integer that indicates the relative order of the objects being 
		/// compared. The return value has these meanings: 
		/// 
		/// Value				Meaning 
		/// Less than zero		This instance is less than <paramref name="obj"/>. 
		/// Zero				This instance is equal to <paramref name="obj"/>. 
		/// Greater than zero	This instance is greater than <paramref name="obj"/>.
		/// </returns>
		/// <exception cref="T:System.ArgumentException">
		/// 	<paramref name="obj"/> is not the same type as this instance. </exception>
		/// ------------------------------------------------------------------------------------
		public override int CompareTo(object obj)
		{
			if (obj == null)
				throw new ArgumentException();

			ScrReference right;
			if (obj is ScrReference)
			{
				right = (ScrReference)obj;

				// If versifications don't match, make a new one, converted to correct versification
				if (m_versification != right.m_versification &&
					m_versification != ScrVers.Unknown &&
					right.m_versification != ScrVers.Unknown)
				{
					// Neither of the versifications involved are unknown, so do a normal conversion
					right = new ScrReference(right, m_versification);
				}
				else if (m_versification != right.m_versification)
				{
					// one of the versifications involved is unknown, so just treat it as the same
					// versification as the known one.
					if (right.m_versification != ScrVers.Unknown)
					{
						ScrReference newThis = new ScrReference(BBCCCVVV, right.m_versification);
						return newThis.CompareTo(right);
					}

					right = new ScrReference(right.BBCCCVVV, m_versification);
				}
			}
			else if (obj is BCVRef)
				right = new ScrReference((BCVRef)obj, m_versification);
			else if (obj is int)
				right = new ScrReference((int)obj, m_versification);
			else
				throw new ArgumentException();

			return base.CompareTo(right);
		}