Esempio n. 1
0
        /// <summary>
        /// Converts the supplied value to the type parameter type (T?) for this class.
        /// </summary>
        /// <param name="hostParameter">Parameter that this value belongs to.</param>
        /// <param name="value">Value to convert, may be null.</param>
        /// <returns>If input value is not null, returns value converted to T?; null otherwise.</returns>
        /// <remarks>Used when setting a parameter value from a control (or anything else that
        /// implements <see cref="IParameterConvertible"/>).<br/><br/>
        /// Unlike all other (non-enumerated) control/parameter relationships, Percentage_t does not have a
        /// one-to-one mapping with its associated control value as the control will typically contain a user-oriented
        /// format (e.g., 25) when the parameter must contain the true value (i.e., 0.25, assuming multiplyBy100
        /// is not set to true).</remarks>
        protected override decimal?ConvertToNativeType(IParameter hostParameter, IParameterConvertible value)
        {
            decimal?convertedValue = value.ToDecimal(hostParameter, CultureInfo.CurrentUICulture);

            return((convertedValue != null) ? convertedValue /= 100 : null);
        }
Esempio n. 2
0
 /// <summary>
 /// Converts the supplied value to the type parameter type (T?) for this class.
 /// </summary>
 /// <param name="hostParameter">Parameter that this value belongs to.</param>
 /// <param name="value">Value to convert, may be null.</param>
 /// <returns>If input value is not null, returns value converted to T?; null otherwise.</returns>
 /// <remarks>Used when setting a parameter value from a control (or anything else that
 /// implements <see cref="IParameterConvertible"/>).</remarks>
 protected override decimal?ConvertToNativeType(IParameter hostParameter, IParameterConvertible value)
 {
     return(value.ToDecimal(hostParameter, CultureInfo.CurrentUICulture));
 }