Fix: Instance type is required

This commit is contained in:
Entoarox 2017-10-13 19:00:55 +02:00 committed by Jesse Plamondon-Willard
parent ded647aad4
commit 191d65f8d9
1 changed files with 4 additions and 2 deletions

View File

@ -51,8 +51,10 @@ namespace StardewModdingAPI.Framework.Reflection
this.Parent = obj; this.Parent = obj;
this.PropertyInfo = property ?? throw new ArgumentNullException(nameof(property)); this.PropertyInfo = property ?? throw new ArgumentNullException(nameof(property));
this.GetterDelegate = (Func<object, TValue>)Delegate.CreateDelegate(typeof(Func<object, TValue>), this.PropertyInfo.GetMethod); Type[] types = new Type[] { this.PropertyInfo.DeclaringType, typeof(TValue)};
this.SetterDelegate = (Action<object, TValue>)Delegate.CreateDelegate(typeof(Action<object, TValue>), this.PropertyInfo.SetMethod);
this.GetterDelegate = (Func<object, TValue>)Delegate.CreateDelegate(typeof(Func<,>).MakeGenericType(types), this.PropertyInfo.GetMethod);
this.SetterDelegate = (Action<object, TValue>)Delegate.CreateDelegate(typeof(Action<,>).MakeGenericType(types), this.PropertyInfo.SetMethod);
} }
/// <summary>Get the property value.</summary> /// <summary>Get the property value.</summary>