zoukankan      html  css  js  c++  java
  • C#类型转换3

    namespace WDBuyNET.DMSFrame.Utils
    {
        public static class TypeExtentions
        {
            public static bool IsPrimitive(this Type t)
            {
                bool result;
                if (t.IsGenericType)
                {
                    result = (TypeExtentions.IsNullableType(t) && TypeExtentions.IsPrimitive(Nullable.GetUnderlyingType(t)));
                }
                else
                {
                    bool arg_14F_0;
                    if (!(t == typeof(string)) && !(t == typeof(short)) && !(t == typeof(ushort)) && !(t == typeof(int)) && !(t == typeof(uint)) && !(t == typeof(long)) && !(t == typeof(ulong)) && !(t == typeof(float)) && !(t == typeof(double)) && !(t == typeof(decimal)) && !(t == typeof(char)) && !(t == typeof(byte)) && !(t == typeof(bool)) && !(t == typeof(DateTime)))
                    {
                        arg_14F_0 = (t == typeof(Guid));
                    }
                    else
                    {
                        arg_14F_0 = true;
                    }
                    result = arg_14F_0;
                }
                return result;
            }
            public static bool IsStringType(this Type type)
            {
                bool arg_80_0;
                if (!(type == typeof(string)) && !(type == typeof(bool)) && !(type == typeof(DateTime)) && !(type == typeof(Guid)) && !(type == typeof(bool?)) && !(type == typeof(DateTime?)))
                {
                    arg_80_0 = (type == typeof(Guid?));
                }
                else
                {
                    arg_80_0 = true;
                }
                return arg_80_0;
            }
            public static bool IsBooleanType(this Type type)
            {
                return TypeExtentions.GetUnderlyingType(type) == typeof(bool);
            }
            public static bool AllowsNullValue(this Type type)
            {
                return !type.IsValueType || TypeExtentions.IsNullableType(type);
            }
            public static bool IsNullableType(this Type type)
            {
                return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable);
            }
            public static Type GetUnderlyingType(this Type type)
            {
                return TypeExtentions.IsNullableType(type) ? Nullable.GetUnderlyingType(type) : type;
            }
            public static string Join(this string[] array, char splitChar)
            {
                StringBuilder stringBuilder = new StringBuilder();
                for (int i = 0; i < array.Length; i++)
                {
                    stringBuilder.Append(array[i]);
                    stringBuilder.Append(splitChar);
                }
                return stringBuilder.ToString().TrimEnd(new char[]
                {
                    splitChar
                });
            }
            public static object DefaultValue(this Type type)
            {
                return type.IsValueType ? Activator.CreateInstance(type) : null;
            }
            public static string MD5(this string text)
            {
                byte[] bytes = Encoding.Default.GetBytes(text);
                MD5CryptoServiceProvider mD5CryptoServiceProvider = new MD5CryptoServiceProvider();
                byte[] array = mD5CryptoServiceProvider.ComputeHash(bytes);
                string text2 = "";
                byte[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    byte b = array2[i];
                    text2 = ((b >= 16) ? (text2 + b.ToString("X")) : (text2 + "0" + b.ToString("X")));
                }
                return text2.ToLower();
            }
        }
    }
  • 相关阅读:
    C#操作SQLite 报错 (Attempt to write a readonly database)
    JS判断字符输入个数(数字英文长度记为1,中文记为2,超过长度自动截取)
    JueryUI插件的简单应用(一):介绍及第一个示例
    在VS2008(Winform)中使用WebService
    Oracle触发器使用
    C# 创建Windows服务。服务功能:定时操作数据库
    aspnet前后台条件下根目录的读取
    xshell实现端口转发
    (转)使用FreeType实现矢量字体的粗体、斜体、描边、阴影效果
    D3D坐标系统和几何DirectX Griaphic学习
  • 原文地址:https://www.cnblogs.com/hongjiumu/p/2686622.html
Copyright © 2011-2022 走看看