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);
        }
Пример #2
0
 public MainWindowViewModel()
 {
     _fileEditor = new FileEditor();
     _selectFileCommand = new RelayCommand(SelectFile);
     _openFileCommand = new RelayCommand(OpenFile, () => !_fileEditor.IsFileOpened);
     _closeFileCommand = new RelayCommand(CloseFile, () => _fileEditor.IsFileOpened);
 }
Пример #3
0
        /// <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();
        }
Пример #4
0
 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;
 }
Пример #5
0
        private static void factory()
        {
            Console.WriteLine("Fabryka abstrackji");
            IFileEditor editor = AbstractFactory.GetFileEditor("D:/test.csv");

            editor.ClearAllText();
            editor.Add("Roman");
            Console.Read();
        }
Пример #6
0
        /// <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
            });
        }
Пример #7
0
 public Versioner(ISourceResolver resolver, IFileEditor editor)
 {
     this.resolver = resolver;
     this.editor   = editor;
 }
Пример #8
0
 public static void ClearCache() => CachedEditor = null;