src/DotNetCommon.Core/Extensions/ObjectExtensions.cs
(开头部分) 63KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using DotNetCommon.Serialize;
using System;
using System.Collections.Generic;
using System.Linq;
using DotNetCommon.Extensions;
using DotNetCommon.Logger;
using System.Reflection;
using System.Text.Json;
using System.Linq.Expressions;
using System.Text.Json.Nodes;
namespace DotNetCommon.Extensions
{
/// <summary>
/// 通用对象扩展方法
/// </summary>
public static class ObjectExtensions
{
private static ILogger logger = LoggerFactory.CreateLogger("DotNetCommon.Extensions.ObjectExtensions");
private static readonly TimeSpan timeSpan = TimeSpan.FromHours(8);
static ObjectExtensions()
{
var now = DateTime.Now;
var utcNow = now.ToUniversalTime();
timeSpan = now - utcNow;
}
#region 私有方法,使用Convert类进行转换
private static List<TypeCode> _baseTypes = new List<TypeCode>
{
TypeCode.Byte,TypeCode.SByte,
TypeCode.Int16,TypeCode.UInt16,
TypeCode.Int32,TypeCode.UInt32,
TypeCode.Int64,TypeCode.UInt64,
TypeCode.Single,TypeCode.Double,TypeCode.Decimal,
TypeCode.Char,TypeCode.Boolean,TypeCode.String,TypeCode.DateTime
};
private static object _baseConvert(TypeCode typeCode, object value)
{
switch (typeCode)
{
case TypeCode.Byte:
{
return Convert.ToByte(value);
}
case TypeCode.SByte:
{
return Convert.ToSByte(value);
}
case TypeCode.Int16:
{
return Convert.ToInt16(value);
}
case TypeCode.UInt16:
{
return Convert.ToUInt16(value);
}
case TypeCode.Int32:
后面还有 1365 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
