Example #1
0
        public SourceText OpenFrom(string loadPath)
        {
            if (TemporaryFileMaker.IsCollectFormat(loadPath))
            {
                return(LoadTemporry(loadPath));
            }

            var text = File.ReadAllText(loadPath);

            _saveFilePath          = loadPath;
            _temporaryFileTextHash = _saveFileTextHash = Guid.NewGuid();
            ForceDeleteTemporaryFile();
            return(new SourceText(_saveFileTextHash, text));
        }
Example #2
0
        public void SaveToTemporary(SourceText sourceText)
        {
            if (sourceText.Guid == _temporaryFileTextHash)
            {
                return;
            }
            if (sourceText.Guid == _saveFileTextHash)
            {
                return;
            }
            if (string.IsNullOrEmpty(_temporaryFilePath))
            {
                _temporaryFilePath = TemporaryFileMaker.Create();
            }
            var tempFile = new TempFileInfo()
            {
                OriginalFilePath = _saveFilePath,
                SourceCode       = sourceText.Text,
            };

            Json.Save(tempFile, _temporaryFilePath);
            _temporaryFileTextHash = sourceText.Guid;
        }