/// <summary> /// 导入对象 /// </summary> public static void ImportObject(Action <object> action , string defaultFileName = null , params string[] defaultFileExtentions) { string fileName = defaultFileName; string[] fileExtentions; if (defaultFileExtentions.IsNotNullOrEmpty()) { fileExtentions = defaultFileExtentions; } else { fileExtentions = new string[] { FileExtentions.CONFIG , FileExtentions.XML , FileExtentions.All }; } if (UIPublic.ShowOpenFileDialog("导入", ref fileName , fileExtentions) == DialogReturn.OK) { if (!File.Exists(fileName)) { UIPublic.ShowErrorDialog("选择的文件不存在"); } else { var obj = IOPublic.ReadObjectFromFile(fileName); try { action(obj); } catch (Exception err) { UIPublic.ShowErrorDialog(err.Message); } } } }