public static Object Convert(String value, Type type)
 {
     if (OptionTypeConverter.IsSupportedType(type))
     {
         return(OptionTypeConverter.types[type].DynamicInvoke(value));
     }
     else
     {
         throw new NotSupportedException();
     }
 }
        /// <summary>
        /// Tries to convert provided value into its expected type.
        /// </summary>
        /// <remarks>
        /// This method tries to convert provided <paramref name="value"/>
        /// into its expected <paramref name="type"/>.
        /// </remarks>
        /// <param name="value">
        /// The option string to be converted.
        /// </param>
        /// <param name="type">
        /// The expected option type.
        /// </param>
        /// <param name="result">
        /// The output parameter to retrieve the conversion result.
        /// </param>
        /// <param name="error">
        /// An instance of type <see cref="Exception"/> to retrieve errors.
        /// </param>
        /// <returns>
        /// True if type conversion was successful and false otherwise.
        /// </returns>
        public static Boolean TryConvert(String value, Type type, out Object result, out Exception error)
        {
            error  = null;
            result = null;
            try
            {
                result = OptionTypeConverter.Convert(value, type);
                return(true);
            }
            catch (Exception exception)
            {
                error = exception;

                if (exception is TargetInvocationException)
                {
                    if (exception.InnerException != null)
                    {
                        error = exception.InnerException;
                    }
                }

                return(false);
            }
        }
 /// <summary>
 /// Tries to convert provided value into its expected type.
 /// </summary>
 /// <remarks>
 /// This method tries to convert provided <paramref name="value"/>
 /// into its expected <paramref name="type"/>.
 /// </remarks>
 /// <param name="value">
 /// The option string to be converted.
 /// </param>
 /// <param name="type">
 /// The expected option type.
 /// </param>
 /// <param name="result">
 /// The output parameter to retrieve the conversion result.
 /// </param>
 /// <returns>
 /// True if type conversion was successful and false otherwise.
 /// </returns>
 public static Boolean TryConvert(String value, Type type, out Object result)
 {
     return(OptionTypeConverter.TryConvert(value, type, out result, out Exception error));
 }