コード例 #1
0
ファイル: FileUtility.cs プロジェクト: ichengzi/SharpDevelop
 static FileOperationResult ObservedSaveHandleException(Exception e, FileOperationDelegate saveFile, FileName fileName, string message, FileErrorPolicy policy)
 {
     var messageService = ServiceSingleton.GetRequiredService<IMessageService>();
     switch (policy) {
         case FileErrorPolicy.Inform:
             messageService.InformSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e);
             break;
         case FileErrorPolicy.ProvideAlternative:
             ChooseSaveErrorResult r = messageService.ChooseSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e, false);
             if (r.IsRetry) {
                 return ObservedSave(saveFile, fileName, message, policy);
             } else if (r.IsIgnore) {
                 return FileOperationResult.Failed;
             }
             break;
     }
     return FileOperationResult.Failed;
 }
コード例 #2
0
 public FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, string fileName, string message, FileErrorPolicy policy)
 {
     Debug.Assert(IsValidFileName(fileName));
     #if false
     try {
         fileName = System.IO.Path.GetFullPath (fileName);
         saveFileAs(fileName);
         return FileOperationResult.OK;
     } catch (Exception e) {
         switch (policy) {
             case FileErrorPolicy.Inform:
                 using (SaveErrorInformDialog informDialog = new SaveErrorInformDialog(fileName, message, "Error while saving", e)) {
                     informDialog.ShowDialog();
                 }
                 break;
             case FileErrorPolicy.ProvideAlternative:
                 restartlabel:
                     using (SaveErrorChooseDialog chooseDialog = new SaveErrorChooseDialog(fileName, message, "Error while saving", e, true)) {
                         switch (chooseDialog.ShowDialog()) {
                             case DialogResult.OK:
                                 using (SaveFileDialog fdiag = new SaveFileDialog()) {
                                     fdiag.OverwritePrompt = true;
                                     fdiag.AddExtension    = true;
                                     fdiag.CheckFileExists = false;
                                     fdiag.CheckPathExists = true;
                                     fdiag.Title           = "Choose alternate file name";
                                     fdiag.FileName        = fileName;
                                     if (fdiag.ShowDialog() == DialogResult.OK) {
                                         return ObservedSave(saveFileAs, fdiag.FileName, message, policy);
                                     } else {
                                         goto restartlabel;
                                     }
                                 }
                                 case DialogResult.Retry:
                                     return ObservedSave(saveFileAs, fileName, message, policy);
                             case DialogResult.Ignore:
                                 return FileOperationResult.Failed;
                         }
                     }
                     break;
         }
     }
     #else
     try {
         saveFileAs(fileName);
         return FileOperationResult.OK;
     } catch (Exception e) {
         Console.WriteLine("Error while saving as : " + e.ToString());
     }
     #endif
     return FileOperationResult.Failed;
 }
コード例 #3
0
        public static FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, string fileName, string message, FileErrorPolicy policy)
        {
            try
            {
                string directoryName = Path.GetDirectoryName(fileName);
                if (!Directory.Exists(directoryName))
                {
                    Directory.CreateDirectory(directoryName);
                }
                saveFileAs(fileName);
                OnFileSaved(new FileNameEventArgs(fileName));
                return FileOperationResult.OK;
            }
            catch (Exception exception)
            {
                switch (policy)
                {
                    case FileErrorPolicy.Inform:
                        using (SaveErrorInformDialog dialog = new SaveErrorInformDialog(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", exception))
                        {
                            dialog.ShowDialog();
                        }
                        goto Label_016F;

                    case FileErrorPolicy.ProvideAlternative:
                        goto Label_0084;

                    default:
                        goto Label_016F;
                }
            Label_0084:
                using (SaveErrorChooseDialog dialog2 = new SaveErrorChooseDialog(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", exception, true))
                {
                    switch (dialog2.ShowDialog())
                    {
                        case DialogResult.OK:
                        {
                            using (SaveFileDialog dialog3 = new SaveFileDialog())
                            {
                                dialog3.OverwritePrompt = true;
                                dialog3.AddExtension = true;
                                dialog3.CheckFileExists = false;
                                dialog3.CheckPathExists = true;
                                dialog3.Title = "Choose alternate file name";
                                dialog3.FileName = fileName;
                                if (dialog3.ShowDialog() == DialogResult.OK)
                                {
                                    return ObservedSave(saveFileAs, dialog3.FileName, message, policy);
                                }
                                goto Label_0084;
                            }
                        }
                        case DialogResult.Cancel:
                        case DialogResult.Abort:
                            goto Label_016F;

                        case DialogResult.Retry:
                            return ObservedSave(saveFileAs, fileName, message, policy);

                        case DialogResult.Ignore:
                            return FileOperationResult.Failed;
                    }
                    goto Label_016F;
                }
            }
            Label_016F:
            return FileOperationResult.Failed;
        }
コード例 #4
0
ファイル: FileUtility.cs プロジェクト: OmerRaviv/SharpDevelop
		public static FileOperationResult ObservedLoad(NamedFileOperationDelegate saveFileAs, string fileName, FileErrorPolicy policy = FileErrorPolicy.Inform)
		{
			return ObservedLoad(saveFileAs,
			                    fileName,
			                    ResourceService.GetString("ICSharpCode.Services.FileUtilityService.CantLoadFileStandardText"),
			                    policy);
		}
コード例 #5
0
 public FileOperationResult ObservedLoad(NamedFileOperationDelegate saveFileAs, string fileName, string message, FileErrorPolicy policy)
 {
     return ObservedLoad(new FileOperationDelegate(new LoadWrapper(saveFileAs, fileName).Invoke), fileName, message, policy);
 }
コード例 #6
0
ファイル: FileUtility.cs プロジェクト: OmerRaviv/SharpDevelop
		static FileOperationResult ObservedSaveHandleError(Exception e, NamedFileOperationDelegate saveFileAs, string fileName, string message, FileErrorPolicy policy)
		{
			switch (policy) {
				case FileErrorPolicy.Inform:
					ServiceManager.Instance.MessageService.InformSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e);
					break;
				case FileErrorPolicy.ProvideAlternative:
					ChooseSaveErrorResult r = ServiceManager.Instance.MessageService.ChooseSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e, true);
					if (r.IsRetry) {
						return ObservedSave(saveFileAs, fileName, message, policy);
					} else if (r.IsIgnore) {
						return FileOperationResult.Failed;
					} else if (r.IsSaveAlternative) {
						return ObservedSave(saveFileAs, r.AlternativeFileName, message, policy);
					}
					break;
			}
			return FileOperationResult.Failed;
		}
コード例 #7
0
ファイル: FileUtility.cs プロジェクト: OmerRaviv/SharpDevelop
		static FileOperationResult ObservedLoadHandleException(Exception e, FileOperationDelegate loadFile, string fileName, string message, FileErrorPolicy policy)
		{
			switch (policy) {
				case FileErrorPolicy.Inform:
					ServiceManager.Instance.MessageService.InformSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileLoading}", e);
					break;
				case FileErrorPolicy.ProvideAlternative:
					ChooseSaveErrorResult r = ServiceManager.Instance.MessageService.ChooseSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileLoading}", e, false);
					if (r.IsRetry)
						return ObservedLoad(loadFile, fileName, message, policy);
					else if (r.IsIgnore)
						return FileOperationResult.Failed;
					break;
			}
			return FileOperationResult.Failed;
		}
コード例 #8
0
ファイル: FileUtil.cs プロジェクト: vincentvalenlee/XCRM
 public static FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, string fileName, FileErrorPolicy policy)
 {
     return ObservedSave(saveFileAs,
                         fileName,
                         ResourceService.GetString("ECBC.Services.FileUtil.CantSaveFileStandardText"),
                         policy);
 }
コード例 #9
0
 // Observe LOAD functions
 public static FileOperationResult ObservedLoad(FileOperationDelegate loadFile, string fileName, string message, FileErrorPolicy policy)
 {
     try {
         loadFile();
         OnFileLoaded(new FileNameEventArgs(fileName));
         return FileOperationResult.OK;
     } catch (Exception e) {
         switch (policy) {
             case FileErrorPolicy.Inform:
                 ServiceManager.MessageService.InformSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileLoading}", e);
                 break;
             case FileErrorPolicy.ProvideAlternative:
                 ChooseSaveErrorResult r = ServiceManager.MessageService.ChooseSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileLoading}", e, false);
                 if (r.IsRetry)
                     return ObservedLoad(loadFile, fileName, message, policy);
                 else if (r.IsIgnore)
                     return FileOperationResult.Failed;
                 break;
         }
     }
     return FileOperationResult.Failed;
 }
コード例 #10
0
ファイル: FileUtil.cs プロジェクト: vincentvalenlee/XCRM
 public static FileOperationResult ObservedLoad(FileOperationDelegate loadFile, string fileName, FileErrorPolicy policy)
 {
     return ObservedLoad(loadFile,
                         fileName,
                         ResourceService.GetString("ECBC.Services.FileUtil.CantLoadFileStandardText"),
                         policy);
 }
コード例 #11
0
ファイル: FileUtil.cs プロジェクト: vincentvalenlee/XCRM
 /// <summary>
 /// 执行保存方法,并进行监视。如果保存出现异常,则根据FileErrorPolicy
 /// 策略的值使用Message服务执行日志记录
 /// </summary>
 /// <param name="saveFile">保存文件委托</param>
 /// <param name="fileName">文件名</param>
 /// <returns>文件操作枚举值</returns>
 public static FileOperationResult ObservedSave(FileOperationDelegate saveFile, string fileName, string message, FileErrorPolicy policy)
 {
     System.Diagnostics.Debug.Assert(IsValidPath(fileName));
     try {
         saveFile();
         RaiseFileSaved(new FileNameEventArgs(fileName));
         return FileOperationResult.OK;
     } catch (Exception e) {
         switch (policy) {
             case FileErrorPolicy.Inform:
                 ServiceManager.MessageService.InformSaveError(fileName, message, "${res:FileUtil.ErrorWhileSaving}", e);
                 break;
             case FileErrorPolicy.ProvideAlternative:
                 ChooseSaveErrorResult r = ServiceManager.MessageService.ChooseSaveError(fileName, message, "${res:FileUtil.ErrorWhileSaving}", e, false);
                 if (r.IsRetry) {
                     return ObservedSave(saveFile, fileName, message, policy);
                 } else if (r.IsIgnore) {
                     return FileOperationResult.Failed;
                 }
                 break;
         }
     }
     return FileOperationResult.Failed;
 }
コード例 #12
0
		public FileOperationResult ObservedLoad(NamedFileOperationDelegate loadFileAsDelegate, string fileName, FileErrorPolicy policy)
		{
			string cantLoadFileStandardText = resourceService.GetString("NetFocus.Services.FileUtilityService.CantLoadFileStandardText");

			return ObservedLoad(loadFileAsDelegate,fileName,cantLoadFileStandardText,policy);
		}
コード例 #13
0
		public FileOperationResult ObservedLoad(NamedFileOperationDelegate loadNamedFileDelegate, string fileName, string message, FileErrorPolicy policy)
		{
			LoadWrapper loadWrapper = new LoadWrapper(loadNamedFileDelegate, fileName);
			FileOperationDelegate fileOperationDelegate = new FileOperationDelegate(loadWrapper.Invoke);
			return ObservedLoad(fileOperationDelegate, fileName, message, policy);
		}
コード例 #14
0
		public FileOperationResult ObservedLoad(FileOperationDelegate loadFileDelegate, string fileName, string message, FileErrorPolicy policy)
		{
			Debug.Assert(IsValidFileName(fileName));
			//Eventually do the load file action.
			try 
			{
				loadFileDelegate();//通过这个委托来真正最后调用实际的方法,所有的ObservedLoad方法
				//无论是NamedFileOperation还是FileOperation最终都会通过这个委托来调用所对应的方�?
				return FileOperationResult.OK;
			} 
			catch (Exception e) 
			{
				switch (policy) 
				{
					case FileErrorPolicy.Inform:
						using (SaveErrorInformDialog informDialog = new SaveErrorInformDialog(fileName, message, "Error while loading", e)) 
						{
							informDialog.ShowDialog();
						}
						break;
					case FileErrorPolicy.ProvideAlternative:
						using (SaveErrorChooseDialog chooseDialog = new SaveErrorChooseDialog(fileName, message, "Error while loading", e, false)) 
						{
							switch (chooseDialog.ShowDialog()) 
							{
								case DialogResult.OK: // choose location (never happens here)
									break;
								case DialogResult.Retry:
									return ObservedLoad(loadFileDelegate, fileName, message, policy);
								case DialogResult.Ignore:
									return FileOperationResult.Failed;
							}
						}
						break;
				}
			}
			return FileOperationResult.Failed;
		}
コード例 #15
0
ファイル: FileUtility.cs プロジェクト: OmerRaviv/SharpDevelop
		// Observe SAVE functions
		public static FileOperationResult ObservedSave(FileOperationDelegate saveFile, string fileName, string message, FileErrorPolicy policy = FileErrorPolicy.Inform)
		{
			System.Diagnostics.Debug.Assert(IsValidPath(fileName));
			try {
				saveFile();
				RaiseFileSaved(new FileNameEventArgs(fileName));
				return FileOperationResult.OK;
			} catch (IOException e) {
				return ObservedSaveHandleException(e, saveFile, fileName, message, policy);
			} catch (UnauthorizedAccessException e) {
				return ObservedSaveHandleException(e, saveFile, fileName, message, policy);
			}
		}
コード例 #16
0
 public static FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, string fileName, string message, FileErrorPolicy policy)
 {
     System.Diagnostics.Debug.Assert(IsValidPath(fileName));
     try {
         string directory = Path.GetDirectoryName(fileName);
         if (!Directory.Exists(directory)) {
             Directory.CreateDirectory(directory);
         }
         saveFileAs(fileName);
         RaiseFileSaved(new FileNameEventArgs(fileName));
         return FileOperationResult.OK;
     } catch (Exception e) {
         switch (policy) {
             case FileErrorPolicy.Inform:
                 ServiceManager.MessageService.InformSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e);
                 break;
             case FileErrorPolicy.ProvideAlternative:
                 ChooseSaveErrorResult r = ServiceManager.MessageService.ChooseSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e, true);
                 if (r.IsRetry) {
                     return ObservedSave(saveFileAs, fileName, message, policy);
                 } else if (r.IsIgnore) {
                     return FileOperationResult.Failed;
                 } else if (r.IsSaveAlternative) {
                     return ObservedSave(saveFileAs, r.AlternativeFileName, message, policy);
                 }
                 break;
         }
     }
     return FileOperationResult.Failed;
 }
コード例 #17
0
ファイル: FileUtility.cs プロジェクト: OmerRaviv/SharpDevelop
		public static FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, string fileName, string message, FileErrorPolicy policy = FileErrorPolicy.Inform)
		{
			System.Diagnostics.Debug.Assert(IsValidPath(fileName));
			try {
				string directory = Path.GetDirectoryName(fileName);
				if (!Directory.Exists(directory)) {
					Directory.CreateDirectory(directory);
				}
				saveFileAs(fileName);
				RaiseFileSaved(new FileNameEventArgs(fileName));
				return FileOperationResult.OK;
			} catch (IOException e) {
				return ObservedSaveHandleError(e, saveFileAs, fileName, message, policy);
			} catch (UnauthorizedAccessException e) {
				return ObservedSaveHandleError(e, saveFileAs, fileName, message, policy);
			}
		}
コード例 #18
0
 public static FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, FileName fileName, FileErrorPolicy policy = FileErrorPolicy.Inform)
 {
     return ObservedSave(saveFileAs,
                         fileName,
                         (string)LocalizeDictionary.Instance.GetLocalizedObject("BVEEditor", "StringResources", "Services_FileUtilities_CantSaveFileStandardText", LocalizeDictionary.CurrentCulture),
                         policy);
 }
コード例 #19
0
ファイル: FileUtility.cs プロジェクト: OmerRaviv/SharpDevelop
		// Observe LOAD functions
		public static FileOperationResult ObservedLoad(FileOperationDelegate loadFile, string fileName, string message, FileErrorPolicy policy)
		{
			try {
				loadFile();
				OnFileLoaded(new FileNameEventArgs(fileName));
				return FileOperationResult.OK;
			} catch (IOException e) {
				return ObservedLoadHandleException(e, loadFile, fileName, message, policy);
			}  catch (UnauthorizedAccessException e) {
				return ObservedLoadHandleException(e, loadFile, fileName, message, policy);
			}
		}
コード例 #20
0
ファイル: FileUtility.cs プロジェクト: stophun/fdotoolbox
		public static FileOperationResult ObservedSave(FileOperationDelegate saveFile, string fileName, FileErrorPolicy policy)
		{
			return ObservedSave(saveFile,
			                    fileName,
			                    ResourceService.GetString("ICSharpCode.Services.FileUtilityService.CantSaveFileStandardText"),
			                    policy);
		}
コード例 #21
0
ファイル: FileUtility.cs プロジェクト: OmerRaviv/SharpDevelop
		public static FileOperationResult ObservedLoad(NamedFileOperationDelegate saveFileAs, string fileName, string message, FileErrorPolicy policy = FileErrorPolicy.Inform)
		{
			return ObservedLoad(new FileOperationDelegate(delegate { saveFileAs(fileName); }), fileName, message, policy);
		}
コード例 #22
0
ファイル: FileUtility.cs プロジェクト: stophun/fdotoolbox
		public static FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, string fileName, string message, FileErrorPolicy policy)
		{
			System.Diagnostics.Debug.Assert(IsValidFileName(fileName));
			try {
				string directory = Path.GetDirectoryName(fileName);
				if (!Directory.Exists(directory)) {
					Directory.CreateDirectory(directory);
				}
				saveFileAs(fileName);
				OnFileSaved(new FileNameEventArgs(fileName));
				return FileOperationResult.OK;
			} catch (Exception e) {
				switch (policy) {
					case FileErrorPolicy.Inform:
						using (SaveErrorInformDialog informDialog = new SaveErrorInformDialog(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e)) {
							informDialog.ShowDialog();
						}
						break;
					case FileErrorPolicy.ProvideAlternative:
					restartlabel:
						using (SaveErrorChooseDialog chooseDialog = new SaveErrorChooseDialog(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e, true)) {
							switch (chooseDialog.ShowDialog()) {
								case DialogResult.OK:
									using (SaveFileDialog fdiag = new SaveFileDialog()) {
										fdiag.OverwritePrompt = true;
										fdiag.AddExtension    = true;
										fdiag.CheckFileExists = false;
										fdiag.CheckPathExists = true;
										fdiag.Title           = "Choose alternate file name";
										fdiag.FileName        = fileName;
										if (fdiag.ShowDialog() == DialogResult.OK) {
											return ObservedSave(saveFileAs, fdiag.FileName, message, policy);
										} else {
											goto restartlabel;
										}
									}
								case DialogResult.Retry:
									return ObservedSave(saveFileAs, fileName, message, policy);
								case DialogResult.Ignore:
									return FileOperationResult.Failed;
							}
						}
						break;
				}
			}
			return FileOperationResult.Failed;
		}
コード例 #23
0
 public FileOperationResult ObservedLoad(FileOperationDelegate saveFile, string fileName, FileErrorPolicy policy)
 {
     return ObservedLoad(saveFile,
                         fileName,
                         GettextCatalog.GetString ("Unable to load file."),
                         policy);
 }
コード例 #24
0
ファイル: FileUtility.cs プロジェクト: stophun/fdotoolbox
		// Observe LOAD functions
		public static FileOperationResult ObservedLoad(FileOperationDelegate loadFile, string fileName, string message, FileErrorPolicy policy)
		{
			try {
				loadFile();
				OnFileLoaded(new FileNameEventArgs(fileName));
				return FileOperationResult.OK;
			} catch (Exception e) {
				switch (policy) {
					case FileErrorPolicy.Inform:
						using (SaveErrorInformDialog informDialog = new SaveErrorInformDialog(fileName, message, "${res:FileUtilityService.ErrorWhileLoading}", e)) {
							informDialog.ShowDialog();
						}
						break;
					case FileErrorPolicy.ProvideAlternative:
						using (SaveErrorChooseDialog chooseDialog = new SaveErrorChooseDialog(fileName, message, "${res:FileUtilityService.ErrorWhileLoading}", e, false)) {
							switch (chooseDialog.ShowDialog()) {
								case DialogResult.OK: // choose location (never happens here)
									break;
								case DialogResult.Retry:
									return ObservedLoad(loadFile, fileName, message, policy);
								case DialogResult.Ignore:
									return FileOperationResult.Failed;
							}
						}
						break;
				}
			}
			return FileOperationResult.Failed;
		}
コード例 #25
0
        // Observe SAVE functions
        public FileOperationResult ObservedSave(FileOperationDelegate saveFile, string fileName, string message, FileErrorPolicy policy)
        {
            Debug.Assert(IsValidFileName(fileName));
            #if false
            try {
                saveFile();
                return FileOperationResult.OK;
            } catch (Exception e) {
                switch (policy) {
                    case FileErrorPolicy.Inform:
                        using (SaveErrorInformDialog informDialog = new SaveErrorInformDialog(fileName, message, "Error while saving", e)) {
                            informDialog.ShowDialog();
                        }
                        break;
                    case FileErrorPolicy.ProvideAlternative:
                        using (SaveErrorChooseDialog chooseDialog = new SaveErrorChooseDialog(fileName, message, "Error while saving", e, false)) {
                            switch (chooseDialog.ShowDialog()) {
                                case DialogResult.OK: // choose location (never happens here)
                                break;
                                case DialogResult.Retry:
                                    return ObservedSave(saveFile, fileName, message, policy);
                                case DialogResult.Ignore:
                                    return FileOperationResult.Failed;
                            }
                        }
                        break;
                }
            }
            #else
            try {
                saveFile();
                return FileOperationResult.OK;
            } catch (Exception e) {
                Console.WriteLine("Error while saving : " + e.ToString());
            }

            #endif
            return FileOperationResult.Failed;
        }
コード例 #26
0
ファイル: FileUtility.cs プロジェクト: ichengzi/SharpDevelop
 static FileOperationResult ObservedLoadHandleException(Exception e, FileOperationDelegate loadFile, FileName fileName, string message, FileErrorPolicy policy)
 {
     message = message + Environment.NewLine + Environment.NewLine + e.Message;
     var messageService = ServiceSingleton.GetRequiredService<IMessageService>();
     switch (policy) {
         case FileErrorPolicy.Inform:
             messageService.InformSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileLoading}", e);
             break;
         case FileErrorPolicy.ProvideAlternative:
             ChooseSaveErrorResult r = messageService.ChooseSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileLoading}", e, false);
             if (r.IsRetry)
                 return ObservedLoad(loadFile, fileName, message, policy);
             else if (r.IsIgnore)
                 return FileOperationResult.Failed;
             break;
     }
     return FileOperationResult.Failed;
 }
コード例 #27
0
 public FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, string fileName, FileErrorPolicy policy)
 {
     return ObservedSave(saveFileAs,
                         fileName,
                         GettextCatalog.GetString ("Unable to save file."),
                         policy);
 }
コード例 #28
0
        public static FileOperationResult ObservedSave(FileOperationDelegate saveFile, string fileName, string message, FileErrorPolicy policy)
        {
            try
            {
                saveFile();
                OnFileSaved(new FileNameEventArgs(fileName));
                return FileOperationResult.OK;
            }
            catch (Exception exception)
            {
                switch (policy)
                {
                    case FileErrorPolicy.Inform:
                        using (SaveErrorInformDialog dialog = new SaveErrorInformDialog(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", exception))
                        {
                            dialog.ShowDialog();
                        }
                        goto Label_00C7;

                    case FileErrorPolicy.ProvideAlternative:
                        using (SaveErrorChooseDialog dialog2 = new SaveErrorChooseDialog(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", exception, false))
                        {
                            switch (dialog2.ShowDialog())
                            {
                                case DialogResult.OK:
                                case DialogResult.Cancel:
                                case DialogResult.Abort:
                                    goto Label_00C7;

                                case DialogResult.Retry:
                                    return ObservedSave(saveFile, fileName, message, policy);

                                case DialogResult.Ignore:
                                    return FileOperationResult.Failed;
                            }
                        }
                        goto Label_00C7;
                }
            }
            Label_00C7:
            return FileOperationResult.Failed;
        }