コード例 #1
0
ファイル: Point4DConverter.cs プロジェクト: dox0/DotNet471RS3
        /// <summary>
        /// Attempts to convert to a Point4D from the given object.
        /// </summary>
        /// <returns>
        /// The Point4D which was constructed.
        /// </returns>
        /// <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 Point4D.
        /// </exception>
        /// <param name="context"> The ITypeDescriptorContext for this call. </param>
        /// <param name="culture"> The requested CultureInfo.  Note that conversion uses "en-US" rather than this parameter. </param>
        /// <param name="value"> The object to convert to an instance of Point4D. </param>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value == null)
            {
                throw GetConvertFromException(value);
            }

            String source = value as string;

            if (source != null)
            {
                return(Point4D.Parse(source));
            }

            return(base.ConvertFrom(context, culture, value));
        }