private static CommandBarButtonItem CreateCommandBarButton(object view, MemberInfo member, string title, UIView buttonView, UIBarButtonItemStyle style, UIBarButtonSystemItem?buttonType, BarButtonLocation location)
{
CommandBarButtonItem button = null;
ReflectiveCommand command = null;
var methodInfo = member as MethodInfo;
if (methodInfo != null)
{
command = GetCommandForMember(view, member);
}
if (!string.IsNullOrEmpty(title))
{
button = new CommandBarButtonItem(title, style, (sender, e) => command.Execute(null));
}
else if (buttonView != null)
{
button = new CommandBarButtonItem(buttonView);
}
else
{
if (!buttonType.HasValue)
{
buttonType = UIBarButtonSystemItem.Done;
}
button = new CommandBarButtonItem(buttonType.Value, (sender, e) => command.Execute(null));
button.Style = style;
}
command.CommandButton = button;
button.Enabled = true;
button.Location = location;
button.Command = command;
var orderAttribute = member.GetCustomAttribute <OrderAttribute>();
if (orderAttribute != null)
{
button.Order = orderAttribute.Order;
}
else
{
button.Order = 0;
}
return(button);
}