/// <summary> /// Creates a string representation of this object based on the format string /// and IFormatProvider passed in. /// If the provider is null, the CurrentCulture is used. /// See the documentation for IFormattable for more information. /// </summary> /// <returns> /// A string representation of this object. /// </returns> private string ConvertToString(string format, IFormatProvider provider) { string convertedValue; if (!FontStretches.FontStretchToString(RealStretch, out convertedValue)) { // This can happen only if _stretch member is corrupted. Invariant.Assert(false); } return(convertedValue); }
/// <summary> /// ConvertFrom - attempt to convert to a FontStretch from the given object /// </summary> /// <exception cref="NotSupportedException"> /// A NotSupportedException is thrown if the example object is null or is not a valid type /// which can be converted to a FontStretch. /// </exception> public override object ConvertFrom(ITypeDescriptorContext td, CultureInfo ci, object value) { if (null == value) { throw GetConvertFromException(value); } String s = value as string; if (null == s) { throw new ArgumentException(SR.Get(SRID.General_BadType, "ConvertFrom"), "value"); } FontStretch fontStretch = new FontStretch(); if (!FontStretches.FontStretchStringToKnownStretch(s, ci, ref fontStretch)) { throw new FormatException(SR.Get(SRID.Parsers_IllegalToken)); } return(fontStretch); }