Skip to content

Instantly share code, notes, and snippets.

View MartinZikmund's full-sized avatar
⌨️
Coding

Martin Zikmund MartinZikmund

⌨️
Coding
View GitHub Profile
var s="var s={0}{1}{0};System.Console.Write(s,(char)34,s);";System.Console.Write(s,(char)34,s);
class c{static void Main(){var s="class c{{static void Main(){{var s={0}{1}{0};System.Console.Write(s,(char)34,s);}}}}";System.Console.Write(s,(char)34,s);}}
class c
{
static void Main()
{
var s = "class c{{static void Main(){{var s={0}{1}{0};System.Console.Write(s,(char)34,s);}}}}";
System.Console.Write(s, (char)34, s);
}
}
@MartinZikmund
MartinZikmund / BadgeUpdater.ts
Created September 1, 2021 22:35
BadgeUpdater.ts
interface Navigator {
setAppBadge(value: number): void;
clearAppBadge(): void;
}
namespace Windows.UI.Notifications {
export class BadgeUpdater {
public static setNumber(value: number) {
if (navigator.setAppBadge) {
navigator.setAppBadge(value);
public partial class BadgeUpdater
{
private const string JsType = "Windows.UI.Notifications.BadgeUpdater";
partial void SetBadge(string? value)
{
if (int.TryParse(value, out var number))
{
WebAssemblyRuntime.InvokeJS($"{JsType}.setNumber({number})");
}
public partial class BadgeUpdater
{
private const string BadgeNodeXPath = "/badge";
private const string ValueAttribute = "value";
internal BadgeUpdater()
{
InitPlatform();
}
public static partial class BadgeUpdateManager
{
public static BadgeUpdater CreateBadgeUpdaterForApplication() => new BadgeUpdater();
public static XmlDocument GetTemplateContent(BadgeTemplateType type)
{
// Although UWP has two "template types", both return the same XML.
var xml = new XmlDocument();
xml.LoadXml("<badge value=\"\" />");
return xml;
namespace Windows.UI.Notifications
{
public partial class BadgeNotification
{
public BadgeNotification(XmlDocument content)
{
Content = content ?? throw new ArgumentNullException(nameof(content));
}
public XmlDocument Content { get; }
var badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
XmlElement badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement;
badgeElement.SetAttribute("value", BadgeTextBox.Text);
var badgeNotification = new BadgeNotification(badgeXml);
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeNotification);
await navigator.setAppBadge(42); // Sets the app badge to 42
await navigator.clearAppBadge(); // Clears the app badge