Shared/Kernelx/Kernelx/Cmpts/ServiceModels/ServiceModelExtension.cs

(开头部分) 7KB

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

using Kernelx.Contexts;
using Kernelx.Extensions;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using Kernelx.Data;
using Kernelx.Cmpts.ServiceModels.Default;

#if NETSTANDARD2_0

using System.ComponentModel.DataAnnotations;

#endif

#if NET35
using Kernelx.ComponentModel.DataAnnotations;

#endif


namespace Kernelx.Cmpts.ServiceModels
{

    /// <summary>
    /// 
    /// </summary>
    public static class ServiceModelExtension
    { 

        private static readonly IJsonSerializer _jsonSerializer=ContextWorkload.Current.GetJsonSerializer();



        [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:命名样式", Justification = "<挂起>")]
        internal static object _Convert(string paramName,Type propType,object value)
        { 
            try
            {
                if (propType != typeof(string) && (propType.IsClass || propType.IsDerived(typeof(IEnumerable))))
                    return _jsonSerializer.DeserializeObject(value.ToString(), propType);
                return value.ConvertTo(propType);
            }
            catch (Exception ex)
            {
                throw new ApplicationException($"参数[{paramName}]:'{value}' 格式不正确", ex);
            } 
        }
         
         
        #region 获取指定类型的主键属性对象

        private static readonly Dictionary<Type, PropertyInfo> _primContainer = new Dictionary<Type, PropertyInfo>(); 
        /// <summary>
        /// 获取<paramref name="type"/> 类型中标记了[Key]特性的主键属性对象
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
后面还有 132 行代码,解锁后查看完整代码

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

AI 解读

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

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