private static void AssertButtonPayload(string expectedButtonXml, IToastButton button) { AssertActionsPayload("<actions>" + expectedButtonXml + "</actions>", new ToastActionsCustom() { Buttons = { button } }); }
/// <summary> /// Add a button to the current toast. /// </summary> /// <param name="button">An instance of class that implement <see cref="IToastButton"/> for the button that will be used on the toast.</param> /// <returns>The current instance of <see cref="ToastContentBuilder"/></returns> public ToastContentBuilder AddButton(IToastButton button) { if (button is ToastButton toastButton && toastButton.Content == null) { throw new InvalidOperationException("Content is required on button."); } // List has max 5 buttons if (ButtonList.Count == 5) { throw new InvalidOperationException("A toast can't have more than 5 buttons"); } if (button is ToastButton b && b.CanAddArguments()) { foreach (var arg in _genericArguments) { if (!b.ContainsArgument(arg.Key)) { b.AddArgument(arg.Key, arg.Value); } } } ButtonList.Add(button); return(this); }
/// <summary> /// Add a button to the current toast. /// </summary> /// <param name="button">An instance of class that implement <see cref="IToastButton"/> for the button that will be used on the toast.</param> /// <returns>The current instance of <see cref="ToastContentBuilder"/></returns> public ToastContentBuilder AddButton(IToastButton button) { // List has max 5 buttons if (ButtonList.Count == 5) { throw new InvalidOperationException("A toast can't have more than 5 buttons"); } ButtonList.Add(button); return(this); }
private static Element_ToastAction ConvertToActionElement(IToastButton button) { if (button is ToastButton) return (button as ToastButton).ConvertToElement(); else if (button is ToastButtonDismiss) return (button as ToastButtonDismiss).ConvertToElement(); else if (button is ToastButtonSnooze) return (button as ToastButtonSnooze).ConvertToElement(); throw new NotImplementedException("Unknown button child: " + button.GetType()); }
private static Element_ToastAction ConvertToActionElement(IToastButton button) { if (button is ToastButton) { return((button as ToastButton).ConvertToElement()); } if (button is ToastButtonDismiss) { return((button as ToastButtonDismiss).ConvertToElement()); } if (button is ToastButtonSnooze) { return((button as ToastButtonSnooze).ConvertToElement()); } throw new NotImplementedException("Unknown button child: " + button.GetType()); }
public IUwpExtension AddButton(IToastButton button) { tbc.AddButton(button); return(this); }