summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/ProtoBuf/SerializationContext.cs
blob: 1259b708163a8ec96c28954d79e63621d26cf251 (plain)
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
using System;

namespace ProtoBuf
{
	public sealed class SerializationContext
	{
		public object Context
		{
			get
			{
				return this.context;
			}
			set
			{
				bool flag = this.context != value;
				if (flag)
				{
					this.ThrowIfFrozen();
					this.context = value;
				}
			}
		}

		internal static SerializationContext Default
		{
			get
			{
				return SerializationContext.@default;
			}
		}

		private bool frozen;

		private object context;

		private static readonly SerializationContext @default = new SerializationContext();

		internal void Freeze()
		{
			this.frozen = true;
		}

		private void ThrowIfFrozen()
		{
			bool flag = this.frozen;
			if (flag)
			{
				throw new InvalidOperationException("The serialization-context cannot be changed once it is in use");
			}
		}

		static SerializationContext()
		{
			SerializationContext.@default.Freeze();
		}
	}
}