using System; using System.Collections.Generic; using System.Reflection; using System.Text; namespace Pole.Orleans.Provider.EntityframeworkCore.Utils { internal static class ReflectionHelper { public static PropertyInfo GetPropertyInfo(string propertyName) { if (propertyName == null) throw new ArgumentNullException(nameof(propertyName)); Type statetype = typeof(T); PropertyInfo idProperty = statetype.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public); if (idProperty == null) throw new GrainStorageConfigurationException( $"Could not find \"{propertyName}\" property on type \"{statetype.FullName}\". Either configure the state locator predicate manually or update your model."); if (!idProperty.CanRead) throw new GrainStorageConfigurationException( $"The property \"{propertyName}\" of type \"{statetype.FullName}\" must have a public getter."); return idProperty; } public static Func GetAccessorDelegate(PropertyInfo pInfo) { return (Func)Delegate.CreateDelegate( typeof(Func), null, pInfo.GetMethod); } } }