Ejemplo n.º 1
0
        public IFile OpenExistingFile(OpenFileArguments arguments)
        {
            if (!File.Exists(arguments.Path))
            {
                throw new FileNotFoundException();
            }
            IFile file;

            if (!arguments.FileDefinition.SupportedFileOperation.HasFlag(SupportedFileOperation.Create))
            {
                file = ReadOnlyFile.OpenExisting(arguments.Path);
            }
            else
            {
                file = StorableFile.OpenExisting(arguments.Path);
            }
            return(file);
        }
Ejemplo n.º 2
0
        private static IReadOnlyCollection <OpenFileArguments> CreateOpenFileArguments(IReadOnlyCollection <string> files, IEditor preferrEditor)
        {
            var arguments = new List <OpenFileArguments>();

            if (!files.Any())
            {
                return(arguments);
            }

            var fdm = IoC.Get <IFileDefinitionManager>();

            foreach (var file in files)
            {
                var fileDefinition = fdm.GetDefinitionByExtension(Path.GetExtension(file));
                var editorId       = Guid.Empty;
                if (preferrEditor != null)
                {
                    editorId = preferrEditor.EditorId;
                }
                var argument = new OpenFileArguments(fileDefinition, file, editorId);
                arguments.Add(argument);
            }
            return(arguments);
        }