Skip to content

Commit 6df4fbc

Browse files
committed
refactor: 增加 CanWrite 过滤
1 parent 7d225d9 commit 6df4fbc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/BootstrapBlazor/Extensions/ObjectExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ private static void EnsureInitialized(this object? instance, bool isAutoInitiali
282282
}
283283

284284
// Reflection performance needs to be optimized here
285-
foreach (var propertyInfo in instance.GetType().GetProperties().Where(p => p.PropertyType.IsClass && p.PropertyType != typeof(string)))
285+
foreach (var propertyInfo in instance.GetType().GetProperties().Where(p => p.PropertyType.IsClass
286+
&& p.PropertyType != typeof(string)
287+
&& p.CanWrite))
286288
{
287289
var type = propertyInfo.PropertyType;
288290
var value = propertyInfo.GetValue(instance, null);

0 commit comments

Comments
 (0)