Exemple #1
0
        ///////////////////////////////////////////////////////////////////////
        /// <summary>Two IntUnit are equal if both their value and their
        /// units are equal. No unit conversion is ever done. An IntUnit
        /// is never equal to a FloatUnit, even if they have the same
        /// value and unit.</summary>
        ///////////////////////////////////////////////////////////////////////
        public override bool Equals(object o)
        {
            if (Object.ReferenceEquals(this, o))
            {
                return(true);
            }


            if (!(o is IntUnit))
            {
                return(false);
            }

            IntUnit other = o as IntUnit;

            return(other.number == number && other.unit == unit);
        }
 ///////////////////////////////////////////////////////////////////////
 /// <summary>Adds a new attribute of type intUnit.</summary>
 /// <param name="name">attribute name</param>
 /// <param name="value">attribute value</param>
 /// <returns>the newly-created GBaseAttribute object</returns>
 ///////////////////////////////////////////////////////////////////////
 public GBaseAttribute AddIntUnitAttribute(string name, IntUnit value)
 {
     return(Add(new GBaseAttribute(name,
                                   GBaseAttributeType.IntUnit,
                                   value.ToString())));
 }
 public void testIntUnitConversion()
 {
     IntUnit fu = new IntUnit(34, "cm");
     Assert.AreEqual(fu, new IntUnit(fu.ToString()));
 }
 ///////////////////////////////////////////////////////////////////////
 /// <summary>Adds a new attribute of type intUnit.</summary>
 /// <param name="name">attribute name</param>
 /// <param name="value">attribute value</param>
 /// <returns>the newly-created GBaseAttribute object</returns>
 ///////////////////////////////////////////////////////////////////////
 public GBaseAttribute AddIntUnitAttribute(string name, IntUnit value)
 {
     return Add(new GBaseAttribute(name,
                                   GBaseAttributeType.IntUnit,
                                   value.ToString()));
 }