protected virtual void Prepare()
{
CommandMap.Clear();
_ActualActionSheet = new UIActionSheet(Title);
_ActualActionSheet.Dismissed += HandleDismissed;
var methods = GetType().GetMethods().Where((methodInfo) => methodInfo.GetCustomAttribute<ButtonAttribute>(true) != null).ToList();
ICommand command = null;
var destroyMethod = methods.Where((methodInfo) => methodInfo.Name == "Destroy").SingleOrDefault();
if (destroyMethod != null)
{
command = ViewParser.GetCommandForMember(this, destroyMethod);
var destroyIndex = AddButtonToSheet(GetTitle(destroyMethod), command);
if (destroyIndex > -1)
_ActualActionSheet.DestructiveButtonIndex = destroyIndex;
}
foreach(var method in methods)
{
if (method.Name != "Cancel" && method.Name != "Destroy")
{
command = ViewParser.GetCommandForMember(this, method);
AddButtonToSheet(GetTitle(method), command);
}
}
var cancelMethod = methods.Where((methodInfo) => methodInfo.Name == "Cancel").SingleOrDefault();
if (cancelMethod != null)
{
command = ViewParser.GetCommandForMember(this, cancelMethod);
var cancelIndex = AddButtonToSheet(GetTitle(cancelMethod), command);
if (cancelIndex > -1)
_ActualActionSheet.CancelButtonIndex = cancelIndex;
}
}