コード例 #1
0
        internal static void GetTypeNameOrTypeId(Type type, out string typeName, out string typeId)
        {
            typeName = null;
            typeId   = null;
            //Edited for .NET Core
            //if (type.IsEnum)
            if (type.GetTypeInfo().IsEnum)
            {
                type = Enum.GetUnderlyingType(type);
            }
            if (type.GetTypeInfo().IsPrimitive || type == typeof(string) || type == typeof(decimal) || type == typeof(DateTime))
            {
                typeName = DataConvert.GetTypeName(type);
                return;
            }
            //Edited for .NET Core
            //ScriptTypeAttribute scriptTypeAttribute = (ScriptTypeAttribute)Attribute.GetCustomAttribute(type, typeof(ScriptTypeAttribute));
            ScriptTypeAttribute scriptTypeAttribute = type.GetTypeInfo().GetCustomAttribute <ScriptTypeAttribute>();

            if (scriptTypeAttribute != null)
            {
                typeId = scriptTypeAttribute.ServerTypeId;
            }
        }