You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ModelBuilder/CommonExtensions.cs
+72Lines changed: 72 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,9 @@
2
2
{
3
3
usingSystem;
4
4
usingSystem.Collections.Generic;
5
+
usingSystem.Linq.Expressions;
6
+
usingSystem.Reflection;
7
+
usingSystem.Runtime.CompilerServices;
5
8
6
9
/// <summary>
7
10
/// The <see cref="CommonExtensions" />
@@ -72,5 +75,74 @@ public static T Set<T>(this T instance, Action<T> action)
72
75
73
76
returninstance;
74
77
}
78
+
79
+
/// <summary>
80
+
/// Supports setting properties with inaccessible setters such as private or protected
81
+
/// Also limited support for setting of readonly auto-properties
82
+
/// </summary>
83
+
/// <typeparam name="T">The type of instance being changed.</typeparam>
84
+
/// <typeparam name="TVALUE">The value to set the expresison function to.</typeparam>
85
+
/// <param name="instance">The instance to update.</param>
86
+
/// <param name="expressionFunc">The expresion function to set against the instance.</param>
87
+
/// <param name="value"></param>
88
+
/// <returns>The updated instance.</returns>
89
+
/// <exception cref="ArgumentNullException">The <paramref name="instance" /> parameter is <c>null</c>.</exception>
90
+
/// <exception cref="ArgumentNullException">The <paramref name="expressionFunc" /> parameter is <c>null</c>.</exception>
91
+
/// <exception cref="NotSupportedException">The <paramref name="expressionFunc" /> parameter is not supported - readonly and complex properties are not supported.</exception>
0 commit comments