コード例 #1
0
        /// <summary>
        /// Converts from Int to String
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is int)
            {
                var myReturn = Enum.ToObject(targetType, value);
                return(((AbilityEnum)myReturn).ToMessage());
            }

            if (value is string)
            {
                // Convert the Message String to the Enum
                var myReturn = AbilityEnumHelper.ConvertMessageStringToEnum((string)value);

                return(myReturn);
            }
            return(0);
        }
コード例 #2
0
        /// <summary>
        /// Converts String to Int
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is Enum)
            {
                //return (int)value;
                return(((AbilityEnum)value).ToMessage());
            }

            if (value is string)
            {
                // Convert String Enum and then Enum to Message
                var myEnum   = AbilityEnumHelper.ConvertMessageStringToEnum((string)value);
                var myReturn = myEnum.ToMessage();

                return(myReturn);
            }

            return(0);
        }