namespace Tiobon.Core.Common;
/// <summary>
/// 视图类属性是字典值时根据属性值获取字典值
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
public sealed class ExportDatatAttribute : Attribute
{
    /// <summary>
    /// 数据源字段名
    /// </summary>
    public string ExportDataName { get; }

    /// <summary>
    /// 数据源的model类型 
    /// </summary>
    public Type ExportDataType { get; }

    /// <summary>
    /// 数据类型，（1）序列 （2）嵌套model （3）数据项
    /// </summary>
    public string ExportDataFlag { get; }

    /// <summary>
    /// 动态数据的字段名和类型
    /// </summary>
    /// <param name="name">数据源字段名</param>
    /// <param name="type">数据源的类型(typeof(类名))</param>
    public ExportDatatAttribute(string name, Type type)
    {
        ExportDataName = name;
        ExportDataType = type;
    }

    /// <summary>
    /// 标识
    /// </summary>
    /// <param name="flag">（1）序列 （2）嵌套model （3）数据项</param>
    public ExportDatatAttribute(string flag)
    {
        ExportDataFlag = flag;
    }
}