diff --git a/framework-dotnet/src/lib/MBS.Core/Reflection/TypeExtensions.cs b/framework-dotnet/src/lib/MBS.Core/Reflection/TypeExtensions.cs index b7930ed..5275b44 100644 --- a/framework-dotnet/src/lib/MBS.Core/Reflection/TypeExtensions.cs +++ b/framework-dotnet/src/lib/MBS.Core/Reflection/TypeExtensions.cs @@ -1,3 +1,5 @@ +using System.Reflection; + namespace MBS.Core.Reflection; public static class TypeExtensions @@ -29,4 +31,18 @@ public static class TypeExtensions return false; } + public static PropertyInfo? GetProperty(this MethodBase methodBase) + { + Type declType = methodBase.DeclaringType; + foreach (PropertyInfo pi in declType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) + { + if (pi.GetMethod == methodBase + || pi.SetMethod == methodBase) + { + return pi; + } + } + return null; + } + } \ No newline at end of file