-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Expand file tree
/
Copy pathStreamingContext.cs
More file actions
62 lines (51 loc) · 2.34 KB
/
Copy pathStreamingContext.cs
File metadata and controls
62 lines (51 loc) · 2.34 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
54
55
56
57
58
59
60
61
62
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
#pragma warning disable CA1066 // Implement IEquatable when overriding Object.Equals
#pragma warning disable SYSLIB0050 // The StreamingContext type is part of the obsolete legacy serialization framework
namespace System.Runtime.Serialization
{
public readonly struct StreamingContext
{
private readonly object? _additionalContext;
[Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
private readonly StreamingContextStates _state;
[Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public StreamingContext(StreamingContextStates state) : this(state, null)
{
}
[Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public StreamingContext(StreamingContextStates state, object? additional)
{
_state = state;
_additionalContext = additional;
}
public override bool Equals([NotNullWhen(true)] object? obj)
{
if (!(obj is StreamingContext))
{
return false;
}
StreamingContext ctx = (StreamingContext)obj;
return ctx._additionalContext == _additionalContext && ctx._state == _state;
}
public override int GetHashCode() => (int)_state;
[Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public StreamingContextStates State => _state;
public object? Context => _additionalContext;
}
[Flags]
[Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public enum StreamingContextStates
{
CrossProcess = 0x01,
CrossMachine = 0x02,
File = 0x04,
Persistence = 0x08,
Remoting = 0x10,
Other = 0x20,
Clone = 0x40,
CrossAppDomain = 0x80,
All = 0xFF,
}
}