コード例 #1
0
        private async Task <KeyValuePair <DicomFile, Stream> > StreamAndStoredFileFromDataset(DicomDataset dataset, int frames = 0, bool disposeStreams = false)
        {
            // Create DicomFile associated with input dataset with random pixel data.
            var dicomFile = new DicomFile(dataset);

            Samples.AppendRandomPixelData(5, 5, frames, dicomFile);

            if (disposeStreams)
            {
                using MemoryStream disposableStream = _recyclableMemoryStreamManager.GetStream();

                // Save file to a stream and reset position to 0.
                await dicomFile.SaveAsync(disposableStream);

                disposableStream.Position = 0;

                return(new KeyValuePair <DicomFile, Stream>(dicomFile, disposableStream));
            }

            MemoryStream stream = _recyclableMemoryStreamManager.GetStream();
            await dicomFile.SaveAsync(stream);

            stream.Position = 0;

            return(new KeyValuePair <DicomFile, Stream>(dicomFile, stream));
        }
コード例 #2
0
        private async Task <(DicomFile, Stream)> StreamAndStoredFileFromDataset(DicomDataset dataset, int frames = 0)
        {
            // Create DicomFile associated with input dataset with random pixel data.
            var dicomFile = new DicomFile(dataset);

            Samples.AppendRandomPixelData(5, 5, frames, dicomFile);

            MemoryStream stream = _recyclableMemoryStreamManager.GetStream();
            await dicomFile.SaveAsync(stream);

            stream.Position = 0;

            return(dicomFile, stream);
        }
コード例 #3
0
        private async Task StoreDatasetsAndInstances(DicomDataset dataset, bool flagToStoreInstance)
        {
            long version = await _indexDataStore.BeginCreateInstanceIndexAsync(1, dataset);

            var versionedInstanceIdentifier = dataset.ToVersionedInstanceIdentifier(version);

            if (flagToStoreInstance)
            {
                var dicomFile = new DicomFile(dataset);

                Samples.AppendRandomPixelData(5, 5, 0, dicomFile);

                await using MemoryStream stream = _recyclableMemoryStreamManager.GetStream();

                dicomFile.Save(stream);
                stream.Position = 0;
                await _fileStore.StoreFileAsync(
                    versionedInstanceIdentifier,
                    stream);
            }

            await _indexDataStore.EndCreateInstanceIndexAsync(1, dataset, version);
        }