src/EasyFrameWork/MetaData/ViewMetaData.cs

(开头部分) 5KB

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

/* http://www.zkea.net/ 
 * Copyright (c) ZKEASOFT. All rights reserved. 
 * http://www.zkea.net/licenses */

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Easy.ViewPort;
using Easy.ViewPort.Descriptor;
using Easy.Constant;
using Easy.Models;
using System.Reflection;
using Easy.Extend;

namespace Easy.MetaData
{
    /// <summary>
    /// 数据元数据特性
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class ViewMetaData<T> : IViewMetaData where T : class
    {
        public ViewMetaData()
        {
            ViewPortDescriptors = new Dictionary<string, BaseDescriptor>();

            TargetType = typeof(T);
            foreach (var item in TargetType.GetProperties())
            {
                Type propertyType= Nullable.GetUnderlyingType(item.PropertyType) ?? item.PropertyType;                
                TypeCode code = Type.GetTypeCode(propertyType);
                switch (code)
                {
                    case TypeCode.Boolean:
                        ViewConfig(item.Name).AsCheckBox();
                        break;

                    case TypeCode.Char:
                        ViewConfig(item.Name).AsTextBox().MaxLength(1).RegularExpression(RegularExpression.Letters);
                        break;

                    case TypeCode.DateTime:
                        ViewConfig(item.Name).AsTextBox().FormatAsDate();
                        break;
                        
                    case TypeCode.Byte:
                    case TypeCode.UInt16:
                    case TypeCode.UInt32:
                    case TypeCode.UInt64:
                        ViewConfig(item.Name).AsTextBox().RegularExpression(RegularExpression.PositiveIntegersAndZero);
                        break;

                    case TypeCode.SByte:
                    case TypeCode.Int16:
                    case TypeCode.Int32:
                    case TypeCode.Int64:
                        ViewConfig(item.Name).AsTextBox().RegularExpression(RegularExpression.Integer);
                        break;

                    case TypeCode.Single:
后面还有 79 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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