Source/FormatHelper.cs

(开头部分) 7KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

#if FRAMEWORK20
using System;
using System.Text;
using System.ComponentModel;
using System.Globalization;
using System.Windows.Forms;

namespace DevComponents.DotNetBar
{
    internal class FormatHelper
    {
        private static Type stringType;
        private static Type checkStateType;
        private static Type booleanType;
 
        /// <summary>
        /// Initializes FormatHelper class.
        /// </summary>
        static FormatHelper()
        {
            stringType = typeof(string);
            booleanType = typeof(bool);
            checkStateType = typeof(CheckState);
            //parseMethodNotFound = new object();
            //defaultDataSourceNullValue = DBNull.Value;
        }
        internal static object FormatObject(object value, Type targetType, TypeConverter sourceConverter, TypeConverter targetConverter, string formatString, IFormatProvider formatInfo, object formattedNullValue, object dataSourceNullValue)
        {
            if (IsNullData(value, dataSourceNullValue))
            {
                value = DBNull.Value;
            }
            Type type = targetType;
            targetType = NullableUnwrap(targetType);
            sourceConverter = NullableUnwrap(sourceConverter);
            targetConverter = NullableUnwrap(targetConverter);
            bool flag = targetType != type;
            object obj2 = FormatObjectInternal(value, targetType, sourceConverter, targetConverter, formatString, formatInfo, formattedNullValue);
            if ((type.IsValueType && (obj2 == null)) && !flag)
            {
                throw new FormatException(GetCantConvertMessage(value, targetType));
            }
            return obj2;
        }

        private static string GetCantConvertMessage(object value, Type targetType)
        {
            string name = (value == null) ? "Can't convert null value" : "Specified format cannot be converted";
            return string.Format(CultureInfo.CurrentCulture, name, new object[] { value, targetType.Name });
        }

 
        private static object FormatObjectInternal(object value, Type targetType, TypeConverter sourceConverter, TypeConverter targetConverter, string formatString, IFormatProvider formatInfo, object formattedNullValue)
        {
            if ((value == DBNull.Value) || (value == null))
            {
                if (formattedNullValue != null)
                {
                    return formattedNullValue;
                }
后面还有 135 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。