Proper error handling for invalid params in WP8

This commit is contained in:
Eddy Verbruggen 2014-07-20 15:04:18 +02:00
parent 8f92ce22eb
commit e6c1c89f14

View File

@ -82,16 +82,30 @@ namespace WPCordovaClassLib.Cordova.Commands
popup.VerticalAlignment = VerticalAlignment.Bottom; popup.VerticalAlignment = VerticalAlignment.Bottom;
popup.VerticalOffset = -100; // TODO can do better popup.VerticalOffset = -100; // TODO can do better
} }
else // center else if ("center".Equals(position))
{ {
popup.VerticalAlignment = VerticalAlignment.Center; popup.VerticalAlignment = VerticalAlignment.Center;
popup.VerticalOffset = -50; // TODO can do way better popup.VerticalOffset = -50; // TODO can do way better
} }
else
{
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "invalid position. valid options are 'top', 'center' and 'bottom'"));
return;
}
int hideDelay = 2800;
if ("long".Equals(duration))
{
hideDelay = 5500;
}
else if (!"short".Equals(duration))
{
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "invalid duration. valid options are 'short' and 'long'"));
return;
}
grid.Children.Add(popup); grid.Children.Add(popup);
popup.IsOpen = true; popup.IsOpen = true;
int hideDelay = "long".Equals(duration) ? 5500 : 2800;
this.hidePopup(hideDelay); this.hidePopup(hideDelay);
} }
} }
@ -108,4 +122,4 @@ namespace WPCordovaClassLib.Cordova.Commands
popup.IsOpen = false; popup.IsOpen = false;
} }
} }
} }