private object OnOpening() { if (!CanOpen()) { return(null); } if (Opening != null) { return(Opening()); } if (typeof(IFile).IsAssignableFrom(cleanType)) { OpenFileDialog ofd = new OpenFileDialog(); CustomizeFileDialog?.Invoke(ofd); if (ofd.ShowDialog() == true) { return(CreateFile(ofd.FileName)); } return(null); } throw new NotSupportedException(FileMessage.OpeningHasNotDefaultImplementationFor0.NiceToString().FormatWith(Type)); }
private void OnSaving(object entity) { if (!CanSave()) { return; } if (Saving != null) { Saving(entity); } else if (typeof(IFile).IsAssignableFrom(cleanType)) { IFile file = (IFile)Server.Convert(entity, cleanType); SaveFileDialog sfd = new SaveFileDialog() { FileName = file.FileName }; CustomizeFileDialog?.Invoke(sfd); if (sfd.ShowDialog() == true) { File.WriteAllBytes(sfd.FileName, file.BinaryFile ?? OnResolveBinaryFile(file)); } } else { throw new NotSupportedException(FileMessage.SavingHasNotDefaultImplementationFor0.NiceToString().FormatWith(Type)); } }