Beispiel #1
0
        /// <summary>
        /// Main method.
        /// </summary>
        /// <param name="args">Arguments for the notification.</param>
        static void Main(string[] args)
        {
            //Initialize application type. TODO: Replace this with dependency injection.
            Globals.ApplicationType = ApplicationTypes.UwpConsole;

            // Register AUMID, COM server, and activator
            DesktopNotificationManagerCompat.RegisterAumidAndComServer <NotifierActivator>("AppVNextNotifier");
            DesktopNotificationManagerCompat.RegisterActivator <NotifierActivator>();

            // If launched from a toast notification
            if (args.Contains(DesktopNotificationManagerCompat.TOAST_ACTIVATED_LAUNCH_ARG))
            {
                //TODO: Handle if launched from a toast notification
            }
            else
            {
                var arguments = ArgumentManager.ProcessArguments(args);

                if (arguments == null)
                {
                    WriteLine($"{Globals.HelpForNullMessage}{Globals.HelpForErrors}");
                    ArgumentManager.DisplayHelp();
                }
                else
                {
                    if (arguments.NotificationsCheck)
                    {
                        WriteLine(RegistryHelper.AreNotificationsEnabled(arguments.NotificationCheckAppId));
                    }

                    if (arguments.PushNotificationCheck)
                    {
                        WriteLine(RegistryHelper.ArePushNotificationsEnabled());
                    }

                    if (arguments.VersionInformation)
                    {
                        WriteLine(Globals.GetVersionInformation());
                    }

                    if (arguments.ClearNotifications)
                    {
                        DesktopNotificationManagerCompat.History.Clear();
                    }

                    if (string.IsNullOrEmpty(arguments.Errors) && !string.IsNullOrEmpty(arguments.Message))
                    {
                        SendNotification(arguments);
                        while (arguments.Wait)
                        {
                            System.Threading.Thread.Sleep(500);
                        }
                    }
                    else
                    {
                        WriteLine($"{(arguments.Errors ?? string.Empty)}");
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Main method.
        /// </summary>
        /// <param name="args">Arguments for the notification.</param>
        static void Main(string[] args)
        {
            //Initialize application type. TODO: Replace this with dependency injection.
            Globals.ApplicationType = ApplicationTypes.UwpNative;

            //RegisterBackgroundTask();

            var arguments = ArgumentManager.ProcessArguments(args);

            if (arguments == null)
            {
                WriteLine($"{Globals.HelpForNullMessage}{Globals.HelpForErrors}");
                ArgumentManager.DisplayHelp();
            }
            else
            {
                //////if (arguments.Register)
                //////{
                //////	if (ShortcutHelper.CreateShortcutIfNeeded(arguments.ApplicationId, arguments.ApplicationName))
                //////	{
                //////		WriteLine(string.Format(Globals.HelpForRegisterSuccess, arguments.ApplicationId, arguments.ApplicationName));
                //////	}
                //////	else
                //////	{
                //////		WriteLine(string.Format(Globals.HelpForRegisterFail, arguments.ApplicationId, arguments.ApplicationName));
                //////	}
                //////}

                //////if (arguments.NotificationsCheck)
                //////{
                //////	WriteLine(RegistryHelper.AreNotificationsEnabled(arguments.NotificationCheckAppId));
                //////}

                //////if (arguments.PushNotificationCheck)
                //////{
                //////	WriteLine(RegistryHelper.ArePushNotificationsEnabled());
                //////}

                if (string.IsNullOrEmpty(arguments.Errors) && !string.IsNullOrEmpty(arguments.Message))
                {
                    SendNotification(arguments);
                    while (arguments.Wait)
                    {
                        System.Threading.Thread.Sleep(500);
                    }
                }
                else
                {
                    WriteLine($"{(arguments.Errors ?? string.Empty)}");
                }
            }
        }