コード例 #1
0
        public override Task <Stream> ReadStreamAsync(string name, CancellationToken cancellationToken = default(CancellationToken))
        {
            Contract.ThrowIfTrue(string.IsNullOrWhiteSpace(name));

            if (!PersistenceEnabled)
            {
                return(SpecializedTasks.Default <Stream>());
            }

            if (!TryGetUniqueNameId(name, out var nameId))
            {
                return(SpecializedTasks.Default <Stream>());
            }

            var stream = EsentExceptionWrapper(nameId, _readStreamSolution, cancellationToken);

            return(SpecializedTasks.DefaultOrResult(stream));
        }
コード例 #2
0
        public override Task <Stream> ReadStreamAsync(Project project, string name, CancellationToken cancellationToken = default(CancellationToken))
        {
            Contract.ThrowIfTrue(string.IsNullOrWhiteSpace(name));

            if (!PersistenceEnabled)
            {
                return(SpecializedTasks.Default <Stream>());
            }

            int nameId;

            EsentStorage.Key key;
            if (!TryGetProjectKey(project, out key) ||
                !TryGetUniqueNameId(name, out nameId))
            {
                return(SpecializedTasks.Default <Stream>());
            }

            var stream = EsentExceptionWrapper(key, nameId, _readStream, cancellationToken);

            return(SpecializedTasks.DefaultOrResult(stream));
        }