public static IFileEditor GetFileEditor(string path) { IFileEditor editor = null; string[] array = path.Split('.'); string extention = array[array.Length - 1]; switch (extention) { case "txt": editor = new TxtEditor(path); break; case "xml": editor = new XMLEditor(path); break; case "csv": editor = new CSVEditor(path); break; default: throw new Exception("Nie znany typ edytora"); } return(editor); }
public MainWindowViewModel() { _fileEditor = new FileEditor(); _selectFileCommand = new RelayCommand(SelectFile); _openFileCommand = new RelayCommand(OpenFile, () => !_fileEditor.IsFileOpened); _closeFileCommand = new RelayCommand(CloseFile, () => _fileEditor.IsFileOpened); }
/// <summary> /// Редактирование файла из хранилища /// </summary> /// <param name="filename">Название файла</param> public void EditFile(string filename) { IFileEditor editor = null; vaultConnection.Connect(); vaultConnection.DownloadToEdit(filename); switch (Path.GetExtension(filename)) { case "pdf": editor = pdfFileEditor; break; case "bmp": editor = imageFileEditor; break; default: editor = textFileEditor; break; } editor.Open(filename); vaultConnection.UploadEditedFile(filename); vaultConnection.Disconnect(); }
public MainWindowViewModel() { _fileEditor = new Model.FileEditor(); _selectFileCommand = new RelayCommand(SelectFile); _openFileCommand = new RelayCommand(() => OpenFileAsync(), () => !_fileEditor.IsFileOpened); _closeFileCommand = new RelayCommand(() => CloseFileAsync(), () => _fileEditor.IsFileOpened); StatusColor = Brushes.CornflowerBlue; }
private static void factory() { Console.WriteLine("Fabryka abstrackji"); IFileEditor editor = AbstractFactory.GetFileEditor("D:/test.csv"); editor.ClearAllText(); editor.Add("Roman"); Console.Read(); }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="editor"></param> /// <returns></returns> public FileItem New(string path, IFileEditor editor) { if (editor == null) { throw new ArgumentNullException(nameof(editor)); } return(new FileItem(this) { Path = path, Editor = editor }); }
public Versioner(ISourceResolver resolver, IFileEditor editor) { this.resolver = resolver; this.editor = editor; }
public static void ClearCache() => CachedEditor = null;