Ejemplo n.º 1
0
        private async Task <LoadResult> LoadFile(Func <IStreamManager, IFileSystem> fileSystemAction, UPath path, IStateInfo parentStateInfo, Guid pluginId, LoadFileContext loadFileContext)
        {
            // 1. Create stream manager
            var streamManager = _streamMonitor.CreateStreamManager();

            // 2. Create file system
            var fileSystem = fileSystemAction(streamManager);

            // 3. Find plugin
            IFilePlugin plugin = null;

            if (pluginId != Guid.Empty)
            {
                plugin = _filePluginLoaders.Select(pl => pl.GetPlugin(pluginId)).First();
            }

            var progress  = loadFileContext.Progress ?? _progress;
            var isRunning = progress.IsRunning();

            if (!isRunning)
            {
                progress.StartProgress();
            }

            // 4. Load file
            var loadResult = await _fileLoader.LoadAsync(fileSystem, path, new LoadInfo
            {
                ParentStateInfo      = parentStateInfo,
                StreamManager        = streamManager,
                PluginManager        = this,
                Plugin               = plugin,
                Progress             = progress,
                DialogManager        = new InternalDialogManager(_dialogManager, loadFileContext.Options),
                AllowManualSelection = AllowManualSelection
            });

            if (!isRunning)
            {
                progress.FinishProgress();
            }

            if (!loadResult.IsSuccessful)
            {
                return(loadResult);
            }

            // 5. Add file to loaded files
            lock (_loadedFilesLock)
            {
                _loadedFiles.Add(loadResult.LoadedState);
            }

            return(loadResult);
        }
Ejemplo n.º 2
0
 async Task Load(string name)
 {
     filecontent = await _fileloader.LoadAsync(@"2019.json");
 }