Equals() публичный Метод

public Equals ( object obj ) : bool
obj object
Результат bool
Пример #1
0
        /// <summary>
        /// Compares this Font with another
        /// </summary>
        /// <param name="obj">the other Font</param>
        /// <returns>a value</returns>
        public virtual int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(-1);
            }
            Font font;

            try
            {
                font = (Font)obj;
                if (_baseFont != null && !_baseFont.Equals(font.BaseFont))
                {
                    return(-2);
                }
                if (_family != font.Family)
                {
                    return(1);
                }
                if (_size.ApproxNotEqual(font.Size))
                {
                    return(2);
                }
                if (_style != font.Style)
                {
                    return(3);
                }
                if (_color == null)
                {
                    if (font.Color == null)
                    {
                        return(0);
                    }
                    return(4);
                }
                if (font.Color == null)
                {
                    return(4);
                }
                if (_color.Equals(font.Color))
                {
                    return(0);
                }
                return(4);
            }
            catch
            {
                return(-3);
            }
        }
Пример #2
0
 private bool CompareColors(BaseColor c1, BaseColor c2)
 {
     if (c1 == null && c2 == null)
         return true;
     if (c1 == null || c2 == null)
         return false;
     if (c1 is ExtendedColor)
         return c1.Equals(c2);
     return c2.Equals(c1);
 }
Пример #3
-3
 public virtual void GoodColorTests() {
     String[] colors = {
         "#00FF00", "00FF00", "#0F0", "0F0", "LIme",
         "rgb(0,255,0 )"
     };
     // TODO webColor creates colors with a zero alpha channel (save
     // "transparent"), BaseColor's 3-param constructor creates them with a
     // 0xFF alpha channel. Which is right?!
     BaseColor testCol = new BaseColor(0, 255, 0);
     foreach (String colStr in colors) {
         BaseColor curCol = WebColors.GetRGBColor(colStr);
         Assert.IsTrue(testCol.Equals(curCol), DumpColor(testCol) + "!=" + DumpColor(curCol));
     }
 }