Exemplo n.º 1
0
        protected override IDistributedNotification ToDistributedNotification(INotification notification)
        {
            var distributedNotification = new DistributedNotification
            {
                Title                 = notification.DisplayTitle,
                Content               = notification.DisplayContent,
                AppIconUrl            = AppIconPath(notification.Status),
                NotificationType      = ToDistributedNotificationType(notification.Type),
                NotificationErrorType = ToDistributedErrorType(notification.Status),
                IssueSource           = notification.IssueSource,
                Source                = notification.Source,
                BasedOnNotification   = notification.Guid
            };

            var statusToColorConverter = BuildStatusToBrushConverter.Instance;
            var brushFromStatus        = statusToColorConverter.Convert(notification.Status) as SolidColorBrush ?? statusToColorConverter.DefaultBrush;

            distributedNotification.ColorCode = brushFromStatus.Color.ToUintColor();

            distributedNotification.ContentImageUrl   = CreateNotificationImage(distributedNotification);
            distributedNotification.FeedbackArguments = distributedNotification.ToUriProtocol();

            Log.Debug().Message($"Created Feedback Argument for notification \"{distributedNotification.FeedbackArguments}\".").Write();
            return(distributedNotification);
        }
 private IDistributedNotification?ReadAsDistributedNotification(string path)
 {
     try
     {
         Log.Debug().Message($"Reading content and deserializing \"{path}\".").Write();
         var content = File.ReadAllText(path);
         return(DistributedNotification.FromSerialized(content));
     }
     catch (Exception e)
     {
         Log.Error().Message("Failed to deserialize DistributedNotification.").Exception(e).Write();
         return(null);
     }
     finally
     {
         try
         {
             Log.Info().Message($"Deleting file \"{path}\".").Write();
             File.Delete(path);
         }
         catch (Exception e)
         {
             Log.Error().Message($"Failed to cleanup Notification \"{path}\".").Exception(e).Write();
         }
     }
 }