private static void WriteMessagesToConsole(object sender, EventArgs e) { if (nomsg != false) { return; } foreach (Message m in bridge.lastMessages) { Type typeofM = m.GetType(); if (typeofM == typeof(Error)) { Error msg = (Error)m; Console.WriteLine(@"ERROR : " + msg); } else if (typeofM == typeof(Success)) { Success msg = (Success)m; Console.WriteLine(@"SUCCESS : " + msg); } else if (typeofM == typeof(CreationSuccess)) { CreationSuccess msg = (CreationSuccess)m; Console.WriteLine(@"CREATION SUCCESS : " + msg.id); } else if (typeofM == typeof(DeletionSuccess)) { DeletionSuccess msg = (DeletionSuccess)m; Console.WriteLine(@"DELETION SUCCESS : " + msg.success); } } }
public void Delete(FileInfo file) { Exception exception; if (Delete(file, out exception)) { DeletionSuccess?.Invoke(file); } else { Messages.Enqueue(new Message() { Exception = exception, FilePath = file.FullName, FolderPath = file.DirectoryName }); } }