From 1918c1311255333a96ed36b0bbba5545c52250fe Mon Sep 17 00:00:00 2001 From: FalconFly <12919280+falconfly@user.noreply.gitee.com> Date: Wed, 21 Jun 2023 09:34:51 +0800 Subject: [PATCH] =?UTF-8?q?ExpandProperties=E6=89=A9=E5=B1=95=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=A2=9E=E5=8A=A0=E7=9B=AE=E6=A0=87=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E5=92=8CSetValue=E6=96=B9=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Falcon.SugarApi/ObjectExtend.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Falcon.SugarApi/ObjectExtend.cs b/Falcon.SugarApi/ObjectExtend.cs index 6c8d46e..3480f7b 100644 --- a/Falcon.SugarApi/ObjectExtend.cs +++ b/Falcon.SugarApi/ObjectExtend.cs @@ -86,9 +86,11 @@ namespace Falcon.SugarApi public static IEnumerable ExpandProperties(this object obj) { foreach(PropertyInfo p in obj.GetType().GetProperties()) { yield return new ExpandPropertyInfo { + TargetObj = obj, Name = p.Name, Type = p.PropertyType, Value = p.CanRead ? p.GetValue(obj) : null, + SetValue = new Action(v => p.SetValue(obj,v)), }; } } @@ -176,6 +178,10 @@ namespace Falcon.SugarApi /// public class ExpandPropertyInfo { + /// + /// 目标对象 + /// + public object TargetObj { get; set; } /// /// 属性名 /// @@ -188,6 +194,10 @@ namespace Falcon.SugarApi /// 属性值 /// public object? Value { get; set; } + /// + /// 设置对象值 + /// + public Action SetValue { get; set; } } ///