in Apps/Contoso.Forms.Demo/Contoso.Forms.Demo/App.xaml.cs [211:243]
public static IEnumerable<ErrorAttachmentLog> GetErrorAttachments()
{
var attachments = new List<ErrorAttachmentLog>();
if (Current.Properties.TryGetValue(CrashesContentPage.TextAttachmentKey, out var textAttachment) &&
textAttachment is string text)
{
var attachment = ErrorAttachmentLog.AttachmentWithText(text, "hello.txt");
attachments.Add(attachment);
}
if (Current.Properties.TryGetValue(CrashesContentPage.FileAttachmentKey, out var fileAttachment) &&
fileAttachment is string file)
{
var filePicker = DependencyService.Get<IFilePicker>();
if (filePicker != null)
{
try
{
var result = filePicker.ReadFile(file);
if (result != null)
{
var attachment = ErrorAttachmentLog.AttachmentWithBinary(result.Item1, result.Item2, result.Item3);
attachments.Add(attachment);
}
}
catch (Exception e)
{
AppCenterLog.Warn(LogTag, "Couldn't read file attachment", e);
Current.Properties.Remove(CrashesContentPage.FileAttachmentKey);
}
}
}
return attachments;
}