PSI.Common/AttributeHelper.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PSI.Common.CustomAttributes;
using System.Reflection;
namespace PSI.Common
{
public static class AttributeHelper
{
/// <summary>
/// 获取映射表名
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static string GetTName(this Type type)
{
string tableName = string.Empty;
object[] attrs = type.GetCustomAttributes(false);
foreach (var attr in attrs)
{
if(attr is TableAttribute)
{
TableAttribute tableAttribute = attr as TableAttribute;
tableName = tableAttribute.Name;
}
}
if(string.IsNullOrEmpty(tableName))
{
tableName = type.Name;
}
return tableName;
}
/// <summary>
/// 获取映射列名
/// </summary>
/// <param name="property"></param>
/// <returns></returns>
public static string GetColName(this PropertyInfo property)
{
string columnName = string.Empty;
object[] attrs = property.GetCustomAttributes(false);
foreach (var attr in attrs)
{
if(attr is ColumnAttribute)
{
ColumnAttribute colAttr = attr as ColumnAttribute;
columnName = colAttr.ColName;
}
}
if(string.IsNullOrEmpty(columnName))
{
columnName = property.Name;
}
return columnName;
}
后面还有 57 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。