using System; using System.Reflection; using Bit.App.Abstractions; using Bit.App.Controls; using Xamarin.Forms; namespace Bit.Android.Services { public class ReflectionService : IReflectionService { public Func GetVisualElementOnSizeRequest(ExtendedTableView tableView) { var handle = typeof(VisualElement).GetMethod( "OnSizeRequest", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(double), typeof(double) }, null)?.MethodHandle; if(!handle.HasValue) { throw new ArgumentNullException("handle could not be found."); } var pointer = handle.Value.GetFunctionPointer(); if(pointer == null) { throw new ArgumentNullException("pointer could not be found."); } return (Func)Activator.CreateInstance(typeof(Func), tableView, pointer); } } }