コード例 #1
0
        private async Task <ReviewCodeFileModel> CreateFileAsync(string revisionId, string originalName, Stream fileStream, bool runAnalysis)
        {
            var originalNameExtension = Path.GetExtension(originalName);
            var languageService       = _languageServices.Single(s => s.IsSupportedExtension(originalNameExtension));

            var reviewCodeFileModel = new ReviewCodeFileModel();

            reviewCodeFileModel.HasOriginal = true;
            reviewCodeFileModel.Name        = originalName;

            using (var memoryStream = new MemoryStream())
            {
                await fileStream.CopyToAsync(memoryStream);

                memoryStream.Position = 0;

                CodeFile codeFile = await languageService.GetCodeFileAsync(originalName, memoryStream, runAnalysis);

                InitializeFromCodeFile(reviewCodeFileModel, codeFile);

                memoryStream.Position = 0;
                await _originalsRepository.UploadOriginalAsync(reviewCodeFileModel.ReviewFileId, memoryStream);

                await _codeFileRepository.UpsertCodeFileAsync(revisionId, reviewCodeFileModel.ReviewFileId, codeFile);
            }

            return(reviewCodeFileModel);
        }
コード例 #2
0
        private async Task <ReviewCodeFileModel> CreateReviewCodeFileModel(string revisionId, MemoryStream memoryStream, CodeFile codeFile)
        {
            var reviewCodeFileModel = new ReviewCodeFileModel
            {
                HasOriginal = true,
            };

            InitializeFromCodeFile(reviewCodeFileModel, codeFile);
            memoryStream.Position = 0;
            await _originalsRepository.UploadOriginalAsync(reviewCodeFileModel.ReviewFileId, memoryStream);

            await _codeFileRepository.UpsertCodeFileAsync(revisionId, reviewCodeFileModel.ReviewFileId, codeFile);

            return(reviewCodeFileModel);
        }