Hotel/Common/Data/FieldsBy.cs

(开头部分) 1KB

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

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Omu.ValueInjecter;

namespace Common.Data
{
    public class FieldsBy : KnownTargetValueInjection<string>
    {
        private IEnumerable<string> _ignoredFields = new string[] { };
        private string _format = "{0}";
        private string _nullFormat;
        private string _glue = ",";

        public FieldsBy SetGlue(string g)
        {
            _glue = " " + g + " ";
            return this;
        }

        public FieldsBy IgnoreFields(params string[] fields)
        {
            _ignoredFields = fields;
            return this;
        }

        public FieldsBy SetFormat(string f)
        {
            _format = f;
            return this;
        }

        public FieldsBy SetNullFormat(string f)
        {
            _nullFormat = f;
            return this;
        }

        protected override void Inject(object source, ref string target)
        {
            var sourceProps = source.GetInfos().ToList();
            var s = string.Empty;
            for (var i = 0; i < sourceProps.Count(); i++)
            {
                var prop = sourceProps[i];

                if (prop.GetCustomAttributes(true).Length > 0)
                {
                    int k = prop.GetCustomAttributes(true).OfType<DbFieldAttribute>().Count(atr => !(atr).IsDbField);

                    if (k > 0)
                        continue;
                }

                if (_ignoredFields.Contains(prop.Name.ToLower())) continue;


                if (prop.GetValue(source, null) == DBNull.Value && _nullFormat != null)
后面还有 9 行代码,购买后查看完整代码

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

AI 解读 AI

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

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