forked from dotnet/Open-XML-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadOnlyStream.cs
More file actions
53 lines (39 loc) · 1.52 KB
/
Copy pathReadOnlyStream.cs
File metadata and controls
53 lines (39 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace DocumentFormat.OpenXml.Framework;
internal sealed class ReadOnlyStream : DelegatingStream
{
public ReadOnlyStream(Stream innerStream)
: base(innerStream)
{
}
public override bool CanWrite => false;
public override void Flush()
{
}
public override Task FlushAsync(CancellationToken cancellationToken) => Task.CompletedTask;
public override void SetLength(long value) => throw new NotSupportedException();
public override void Write(byte[] buffer, int offset, int count)
=> throw new NotSupportedException();
#if NET6_0_OR_GREATER
public override void Write(ReadOnlySpan<byte> buffer)
=> throw new NotSupportedException();
#endif
public override void WriteByte(byte value)
=> throw new NotSupportedException();
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
=> throw new NotSupportedException();
#if NET6_0_OR_GREATER
public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default)
=> throw new NotSupportedException();
#endif
public override int WriteTimeout
{
get => throw new InvalidOperationException();
set => throw new InvalidOperationException();
}
}