ViewFile() public static method

public static ViewFile ( string fileName, string caption ) : void
fileName string
caption string
return void
Esempio n. 1
0
        public async Task ViewAsync(string expression, string title) {
            var evaluation = await EvaluateAsync(expression, REvaluationResultProperties.ExpressionProperty, null);
            if (evaluation == null || string.IsNullOrEmpty(evaluation.Expression)) {
                return;
            }

            var functionName = evaluation.Expression;
            var session = _sessionProvider.GetInteractiveWindowRSession();

            string functionCode = await GetFunctionCode(functionName);
            if (!string.IsNullOrEmpty(functionCode)) {

                string tempFile = GetFileName(functionName, title);
                try {
                    if (File.Exists(tempFile)) {
                        File.Delete(tempFile);
                    }

                    using (var sw = new StreamWriter(tempFile)) {
                        sw.Write(functionCode);
                    }

                    await VsAppShell.Current.SwitchToMainThreadAsync();

                    FileViewer.ViewFile(tempFile, functionName);
                    try {
                        File.Delete(tempFile);
                    } catch (IOException) { } catch (AccessViolationException) { }

                } catch (IOException) { } catch (AccessViolationException) { }
            }
        }
Esempio n. 2
0
        public async Task ViewAsync(string expression, string title, CancellationToken cancellationToken = default(CancellationToken))
        {
            var evaluation = await EvaluateAsync(expression, REvaluationResultProperties.ExpressionProperty, null, cancellationToken);

            if (string.IsNullOrEmpty(evaluation?.Expression))
            {
                return;
            }

            var functionName = evaluation.Expression;
            var functionCode = await GetFunctionCode(functionName, cancellationToken);

            if (!string.IsNullOrEmpty(functionCode))
            {
                var tempFile = Path.ChangeExtension(Path.GetTempFileName(), ".r");
                try {
                    if (_fs.FileExists(tempFile))
                    {
                        _fs.DeleteFile(tempFile);
                    }

                    using (var sw = new StreamWriter(tempFile)) {
                        sw.Write(functionCode);
                    }

                    await _workflow.Services.MainThread().SwitchToAsync(cancellationToken);

                    FileViewer.ViewFile(tempFile, functionName);
                    try {
                        _fs.DeleteFile(tempFile);
                    } catch (IOException) { } catch (UnauthorizedAccessException) { }
                } catch (IOException) { } catch (UnauthorizedAccessException) { }
            }
        }
        public async Task ViewFile(string fileName, string tabName, bool deleteFile)
        {
            await VsAppShell.Current.SwitchToMainThreadAsync();

            FileViewer.ViewFile(fileName, tabName);
            try {
                if (deleteFile)
                {
                    File.Delete(fileName);
                }
            } catch (IOException) { } catch (UnauthorizedAccessException) { }
        }
        public async Task ViewFile(string fileName, string tabName, bool deleteFile, CancellationToken cancellationToken)
        {
            await _coreShell.SwitchToMainThreadAsync(cancellationToken);

            try {
                if (File.Exists(fileName))
                {
                    FileViewer.ViewFile(fileName, tabName);
                    if (deleteFile)
                    {
                        File.Delete(fileName);
                    }
                }
            } catch (Exception ex) when(ex is IOException || ex is UnauthorizedAccessException)
            {
                _coreShell.ShowErrorMessage(ex.Message);
            }
        }
Esempio n. 5
0
        public async Task ViewAsync(string expression, string title)
        {
            var evaluation = await EvaluateAsync(expression, REvaluationResultProperties.ExpressionProperty, null);

            if (evaluation == null || string.IsNullOrEmpty(evaluation.Expression))
            {
                return;
            }

            var functionName = evaluation.Expression;
            var session      = _workflow.RSession;

            string functionCode = await GetFunctionCode(functionName);

            if (!string.IsNullOrEmpty(functionCode))
            {
                string tempFile = Path.ChangeExtension(Path.GetTempFileName(), ".r");
                try {
                    if (File.Exists(tempFile))
                    {
                        File.Delete(tempFile);
                    }

                    using (var sw = new StreamWriter(tempFile)) {
                        sw.Write(functionCode);
                    }

                    await VsAppShell.Current.SwitchToMainThreadAsync();

                    FileViewer.ViewFile(tempFile, functionName);
                    try {
                        File.Delete(tempFile);
                    } catch (IOException) { } catch (UnauthorizedAccessException) { }
                } catch (IOException) { } catch (UnauthorizedAccessException) { }
            }
        }