本文整理汇总了C#中DateTimeOffset.ToNSDate方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeOffset.ToNSDate方法的具体用法?C# DateTimeOffset.ToNSDate怎么用?C# DateTimeOffset.ToNSDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeOffset
的用法示例。
在下文中一共展示了DateTimeOffset.ToNSDate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateScheduledToastNotification
/// <summary>
/// Creates a scheduled toast notification with the required values.
/// </summary>
/// <param name="content">Text content.</param>
/// <param name="title">Toast title.</param>
/// <param name="deliveryTime">When to display the toast.</param>
/// <returns></returns>
public static ScheduledToastNotification CreateScheduledToastNotification(string content, string title, DateTimeOffset deliveryTime)
{
#if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE_81
XmlDocument doc = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
var textElements = doc.GetElementsByTagName("text");
textElements[0].InnerText = title;
textElements[1].InnerText = content;
return new ScheduledToastNotification(new Windows.UI.Notifications.ScheduledToastNotification(doc, deliveryTime));
#elif WINDOWS_PHONE
throw new PlatformNotSupportedException();
#elif __ANDROID__
throw new PlatformNotSupportedException();
#elif __IOS__
UILocalNotification localNotification = new UILocalNotification();
localNotification.AlertTitle = title;
localNotification.AlertBody = content;
localNotification.FireDate = deliveryTime.ToNSDate();
localNotification.SoundName = UILocalNotification.DefaultSoundName;
localNotification.RepeatCalendar = global::Foundation.NSCalendar.CurrentCalendar;
localNotification.RepeatInterval = global::Foundation.NSCalendarUnit.Minute;
return new ScheduledToastNotification(localNotification);
#else
return new ScheduledToastNotification(content, title, deliveryTime);
#endif
}