/// <summary> /// Determines if the specified object is equal to the represented by /// this instance. /// </summary> /// <param name="obj">Object to check.</param> /// <returns>Returns a value indicating whether the object is /// equivalent.</returns> public override bool Equals(object obj) { if (obj == null || !(obj is FontUnit)) { return(false); } FontUnit f = (FontUnit)obj; if ((f._type == _type) && (f._value == _value)) { return(true); } return(false); }
/// <summary> /// Converts the specified object into a FontUnit. /// </summary> /// <param name="context">Context matches the desktop framework's /// signature for this method.</param> /// <param name="culture">The culture information.</param> /// <param name="value">The value to convert.</param> /// <returns>Returns the converted object.</returns> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value == null) { return(null); } string stringValue = value as string; if (stringValue != null) { string textValue = stringValue.Trim(); if (textValue.Length == 0) { return(FontUnit.Empty); } return(FontUnit.Parse(textValue, CultureInfo.InvariantCulture)); } else { return(base.ConvertFrom(value)); } }