This commit is contained in:
niko
2026-06-04 11:42:34 +02:00
parent f39ba70a9f
commit e720b98cd1
7488 changed files with 2493818 additions and 0 deletions
+746
View File
@@ -0,0 +1,746 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Google.Protobuf.Reflection;
namespace Google.Protobuf.Collections
{
// Token: 0x0200006F RID: 111
public sealed class MapField<TKey, TValue> : IDeepCloneable<MapField<TKey, TValue>>, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, IEquatable<MapField<TKey, TValue>>, IDictionary, ICollection
{
// Token: 0x0600060B RID: 1547 RVA: 0x000151CC File Offset: 0x000133CC
public MapField<TKey, TValue> Clone()
{
MapField<TKey, TValue> mapField = new MapField<TKey, TValue>();
if (typeof(IDeepCloneable<TValue>).IsAssignableFrom(typeof(TValue)))
{
using (LinkedList<KeyValuePair<TKey, TValue>>.Enumerator enumerator = this.list.GetEnumerator())
{
while (enumerator.MoveNext())
{
KeyValuePair<TKey, TValue> keyValuePair = enumerator.Current;
mapField.Add(keyValuePair.Key, ((IDeepCloneable<TValue>)((object)keyValuePair.Value)).Clone());
}
return mapField;
}
}
mapField.Add(this);
return mapField;
}
// Token: 0x0600060C RID: 1548 RVA: 0x00015264 File Offset: 0x00013464
public void Add(TKey key, TValue value)
{
if (this.ContainsKey(key))
{
throw new ArgumentException("Key already exists in map", "key");
}
this[key] = value;
}
// Token: 0x0600060D RID: 1549 RVA: 0x00015287 File Offset: 0x00013487
public bool ContainsKey(TKey key)
{
ProtoPreconditions.CheckNotNullUnconstrained<TKey>(key, "key");
return this.map.ContainsKey(key);
}
// Token: 0x0600060E RID: 1550 RVA: 0x000152A4 File Offset: 0x000134A4
private bool ContainsValue(TValue value)
{
EqualityComparer<TValue> comparer = EqualityComparer<TValue>.Default;
return this.list.Any((KeyValuePair<TKey, TValue> pair) => comparer.Equals(pair.Value, value));
}
// Token: 0x0600060F RID: 1551 RVA: 0x000152E0 File Offset: 0x000134E0
public bool Remove(TKey key)
{
ProtoPreconditions.CheckNotNullUnconstrained<TKey>(key, "key");
LinkedListNode<KeyValuePair<TKey, TValue>> linkedListNode;
if (this.map.TryGetValue(key, out linkedListNode))
{
this.map.Remove(key);
linkedListNode.List.Remove(linkedListNode);
return true;
}
return false;
}
// Token: 0x06000610 RID: 1552 RVA: 0x00015328 File Offset: 0x00013528
public bool TryGetValue(TKey key, out TValue value)
{
LinkedListNode<KeyValuePair<TKey, TValue>> linkedListNode;
if (this.map.TryGetValue(key, out linkedListNode))
{
value = linkedListNode.Value.Value;
return true;
}
value = default(TValue);
return false;
}
// Token: 0x170001B5 RID: 437
public TValue this[TKey key]
{
get
{
ProtoPreconditions.CheckNotNullUnconstrained<TKey>(key, "key");
TValue tvalue;
if (this.TryGetValue(key, out tvalue))
{
return tvalue;
}
throw new KeyNotFoundException();
}
set
{
ProtoPreconditions.CheckNotNullUnconstrained<TKey>(key, "key");
if (value == null)
{
ProtoPreconditions.CheckNotNullUnconstrained<TValue>(value, "value");
}
KeyValuePair<TKey, TValue> keyValuePair = new KeyValuePair<TKey, TValue>(key, value);
LinkedListNode<KeyValuePair<TKey, TValue>> linkedListNode;
if (this.map.TryGetValue(key, out linkedListNode))
{
linkedListNode.Value = keyValuePair;
return;
}
linkedListNode = this.list.AddLast(keyValuePair);
this.map[key] = linkedListNode;
}
}
// Token: 0x170001B6 RID: 438
// (get) Token: 0x06000613 RID: 1555 RVA: 0x000153F8 File Offset: 0x000135F8
public ICollection<TKey> Keys
{
get
{
return new MapField<TKey, TValue>.MapView<TKey>(this, (KeyValuePair<TKey, TValue> pair) => pair.Key, new Func<TKey, bool>(this.ContainsKey));
}
}
// Token: 0x170001B7 RID: 439
// (get) Token: 0x06000614 RID: 1556 RVA: 0x0001542C File Offset: 0x0001362C
public ICollection<TValue> Values
{
get
{
return new MapField<TKey, TValue>.MapView<TValue>(this, (KeyValuePair<TKey, TValue> pair) => pair.Value, new Func<TValue, bool>(this.ContainsValue));
}
}
// Token: 0x06000615 RID: 1557 RVA: 0x00015460 File Offset: 0x00013660
public void Add(IDictionary<TKey, TValue> entries)
{
ProtoPreconditions.CheckNotNull<IDictionary<TKey, TValue>>(entries, "entries");
foreach (KeyValuePair<TKey, TValue> keyValuePair in entries)
{
this.Add(keyValuePair.Key, keyValuePair.Value);
}
}
// Token: 0x06000616 RID: 1558 RVA: 0x000154C4 File Offset: 0x000136C4
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return this.list.GetEnumerator();
}
// Token: 0x06000617 RID: 1559 RVA: 0x000154D6 File Offset: 0x000136D6
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
// Token: 0x06000618 RID: 1560 RVA: 0x000154DE File Offset: 0x000136DE
void ICollection<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue> item)
{
this.Add(item.Key, item.Value);
}
// Token: 0x06000619 RID: 1561 RVA: 0x000154F4 File Offset: 0x000136F4
public void Clear()
{
this.list.Clear();
this.map.Clear();
}
// Token: 0x0600061A RID: 1562 RVA: 0x0001550C File Offset: 0x0001370C
bool ICollection<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue> item)
{
TValue tvalue;
return this.TryGetValue(item.Key, out tvalue) && EqualityComparer<TValue>.Default.Equals(item.Value, tvalue);
}
// Token: 0x0600061B RID: 1563 RVA: 0x0001553E File Offset: 0x0001373E
void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
{
this.list.CopyTo(array, arrayIndex);
}
// Token: 0x0600061C RID: 1564 RVA: 0x00015550 File Offset: 0x00013750
bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> item)
{
if (item.Key == null)
{
throw new ArgumentException("Key is null", "item");
}
LinkedListNode<KeyValuePair<TKey, TValue>> linkedListNode;
if (this.map.TryGetValue(item.Key, out linkedListNode) && EqualityComparer<TValue>.Default.Equals(item.Value, linkedListNode.Value.Value))
{
this.map.Remove(item.Key);
linkedListNode.List.Remove(linkedListNode);
return true;
}
return false;
}
// Token: 0x170001B8 RID: 440
// (get) Token: 0x0600061D RID: 1565 RVA: 0x000155D4 File Offset: 0x000137D4
public int Count
{
get
{
return this.list.Count;
}
}
// Token: 0x170001B9 RID: 441
// (get) Token: 0x0600061E RID: 1566 RVA: 0x0000761F File Offset: 0x0000581F
public bool IsReadOnly
{
get
{
return false;
}
}
// Token: 0x0600061F RID: 1567 RVA: 0x000155E1 File Offset: 0x000137E1
public override bool Equals(object other)
{
return this.Equals(other as MapField<TKey, TValue>);
}
// Token: 0x06000620 RID: 1568 RVA: 0x000155F0 File Offset: 0x000137F0
public override int GetHashCode()
{
EqualityComparer<TValue> @default = EqualityComparer<TValue>.Default;
int num = 0;
foreach (KeyValuePair<TKey, TValue> keyValuePair in this.list)
{
int num2 = num;
TKey key = keyValuePair.Key;
num = num2 ^ (key.GetHashCode() * 31 + @default.GetHashCode(keyValuePair.Value));
}
return num;
}
// Token: 0x06000621 RID: 1569 RVA: 0x00015670 File Offset: 0x00013870
public bool Equals(MapField<TKey, TValue> other)
{
if (other == null)
{
return false;
}
if (other == this)
{
return true;
}
if (other.Count != this.Count)
{
return false;
}
EqualityComparer<TValue> @default = EqualityComparer<TValue>.Default;
foreach (KeyValuePair<TKey, TValue> keyValuePair in this)
{
TValue tvalue;
if (!other.TryGetValue(keyValuePair.Key, out tvalue))
{
return false;
}
if (!@default.Equals(tvalue, keyValuePair.Value))
{
return false;
}
}
return true;
}
// Token: 0x06000622 RID: 1570 RVA: 0x00015704 File Offset: 0x00013904
public void AddEntriesFrom(CodedInputStream input, MapField<TKey, TValue>.Codec codec)
{
MapField<TKey, TValue>.Codec.MessageAdapter messageAdapter = new MapField<TKey, TValue>.Codec.MessageAdapter(codec);
do
{
messageAdapter.Reset();
input.ReadMessage(messageAdapter);
this[messageAdapter.Key] = messageAdapter.Value;
}
while (input.MaybeConsumeTag(codec.MapTag));
}
// Token: 0x06000623 RID: 1571 RVA: 0x00015748 File Offset: 0x00013948
public void WriteTo(CodedOutputStream output, MapField<TKey, TValue>.Codec codec)
{
MapField<TKey, TValue>.Codec.MessageAdapter messageAdapter = new MapField<TKey, TValue>.Codec.MessageAdapter(codec);
foreach (KeyValuePair<TKey, TValue> keyValuePair in this.list)
{
messageAdapter.Key = keyValuePair.Key;
messageAdapter.Value = keyValuePair.Value;
output.WriteTag(codec.MapTag);
output.WriteMessage(messageAdapter);
}
}
// Token: 0x06000624 RID: 1572 RVA: 0x000157C8 File Offset: 0x000139C8
public int CalculateSize(MapField<TKey, TValue>.Codec codec)
{
if (this.Count == 0)
{
return 0;
}
MapField<TKey, TValue>.Codec.MessageAdapter messageAdapter = new MapField<TKey, TValue>.Codec.MessageAdapter(codec);
int num = 0;
foreach (KeyValuePair<TKey, TValue> keyValuePair in this.list)
{
messageAdapter.Key = keyValuePair.Key;
messageAdapter.Value = keyValuePair.Value;
num += CodedOutputStream.ComputeRawVarint32Size(codec.MapTag);
num += CodedOutputStream.ComputeMessageSize(messageAdapter);
}
return num;
}
// Token: 0x06000625 RID: 1573 RVA: 0x0001585C File Offset: 0x00013A5C
public override string ToString()
{
StringWriter stringWriter = new StringWriter();
JsonFormatter.Default.WriteDictionary(stringWriter, this);
return stringWriter.ToString();
}
// Token: 0x06000626 RID: 1574 RVA: 0x00015881 File Offset: 0x00013A81
void IDictionary.Add(object key, object value)
{
this.Add((TKey)((object)key), (TValue)((object)value));
}
// Token: 0x06000627 RID: 1575 RVA: 0x00015895 File Offset: 0x00013A95
bool IDictionary.Contains(object key)
{
return key is TKey && this.ContainsKey((TKey)((object)key));
}
// Token: 0x06000628 RID: 1576 RVA: 0x000158AD File Offset: 0x00013AAD
IDictionaryEnumerator IDictionary.GetEnumerator()
{
return new MapField<TKey, TValue>.DictionaryEnumerator(this.GetEnumerator());
}
// Token: 0x06000629 RID: 1577 RVA: 0x000158BA File Offset: 0x00013ABA
void IDictionary.Remove(object key)
{
ProtoPreconditions.CheckNotNull<object>(key, "key");
if (!(key is TKey))
{
return;
}
this.Remove((TKey)((object)key));
}
// Token: 0x0600062A RID: 1578 RVA: 0x000158DE File Offset: 0x00013ADE
void ICollection.CopyTo(Array array, int index)
{
((ICollection)this.Select((KeyValuePair<TKey, TValue> pair) => new DictionaryEntry(pair.Key, pair.Value)).ToList<DictionaryEntry>()).CopyTo(array, index);
}
// Token: 0x170001BA RID: 442
// (get) Token: 0x0600062B RID: 1579 RVA: 0x0000761F File Offset: 0x0000581F
bool IDictionary.IsFixedSize
{
get
{
return false;
}
}
// Token: 0x170001BB RID: 443
// (get) Token: 0x0600062C RID: 1580 RVA: 0x00015911 File Offset: 0x00013B11
ICollection IDictionary.Keys
{
get
{
return (ICollection)this.Keys;
}
}
// Token: 0x170001BC RID: 444
// (get) Token: 0x0600062D RID: 1581 RVA: 0x0001591E File Offset: 0x00013B1E
ICollection IDictionary.Values
{
get
{
return (ICollection)this.Values;
}
}
// Token: 0x170001BD RID: 445
// (get) Token: 0x0600062E RID: 1582 RVA: 0x0000761F File Offset: 0x0000581F
bool ICollection.IsSynchronized
{
get
{
return false;
}
}
// Token: 0x170001BE RID: 446
// (get) Token: 0x0600062F RID: 1583 RVA: 0x000142A1 File Offset: 0x000124A1
object ICollection.SyncRoot
{
get
{
return this;
}
}
// Token: 0x170001BF RID: 447
object IDictionary.this[object key]
{
get
{
ProtoPreconditions.CheckNotNull<object>(key, "key");
if (!(key is TKey))
{
return null;
}
TValue tvalue;
this.TryGetValue((TKey)((object)key), out tvalue);
return tvalue;
}
set
{
this[(TKey)((object)key)] = (TValue)((object)value);
}
}
// Token: 0x04000266 RID: 614
private readonly Dictionary<TKey, LinkedListNode<KeyValuePair<TKey, TValue>>> map = new Dictionary<TKey, LinkedListNode<KeyValuePair<TKey, TValue>>>();
// Token: 0x04000267 RID: 615
private readonly LinkedList<KeyValuePair<TKey, TValue>> list = new LinkedList<KeyValuePair<TKey, TValue>>();
// Token: 0x020000C8 RID: 200
private class DictionaryEnumerator : IDictionaryEnumerator, IEnumerator
{
// Token: 0x06000787 RID: 1927 RVA: 0x00017941 File Offset: 0x00015B41
internal DictionaryEnumerator(IEnumerator<KeyValuePair<TKey, TValue>> enumerator)
{
this.enumerator = enumerator;
}
// Token: 0x06000788 RID: 1928 RVA: 0x00017950 File Offset: 0x00015B50
public bool MoveNext()
{
return this.enumerator.MoveNext();
}
// Token: 0x06000789 RID: 1929 RVA: 0x0001795D File Offset: 0x00015B5D
public void Reset()
{
this.enumerator.Reset();
}
// Token: 0x170001D4 RID: 468
// (get) Token: 0x0600078A RID: 1930 RVA: 0x0001796A File Offset: 0x00015B6A
public object Current
{
get
{
return this.Entry;
}
}
// Token: 0x170001D5 RID: 469
// (get) Token: 0x0600078B RID: 1931 RVA: 0x00017977 File Offset: 0x00015B77
public DictionaryEntry Entry
{
get
{
return new DictionaryEntry(this.Key, this.Value);
}
}
// Token: 0x170001D6 RID: 470
// (get) Token: 0x0600078C RID: 1932 RVA: 0x0001798C File Offset: 0x00015B8C
public object Key
{
get
{
KeyValuePair<TKey, TValue> keyValuePair = this.enumerator.Current;
return keyValuePair.Key;
}
}
// Token: 0x170001D7 RID: 471
// (get) Token: 0x0600078D RID: 1933 RVA: 0x000179B4 File Offset: 0x00015BB4
public object Value
{
get
{
KeyValuePair<TKey, TValue> keyValuePair = this.enumerator.Current;
return keyValuePair.Value;
}
}
// Token: 0x04000305 RID: 773
private readonly IEnumerator<KeyValuePair<TKey, TValue>> enumerator;
}
// Token: 0x020000C9 RID: 201
public sealed class Codec
{
// Token: 0x0600078E RID: 1934 RVA: 0x000179D9 File Offset: 0x00015BD9
public Codec(FieldCodec<TKey> keyCodec, FieldCodec<TValue> valueCodec, uint mapTag)
{
this.keyCodec = keyCodec;
this.valueCodec = valueCodec;
this.mapTag = mapTag;
}
// Token: 0x170001D8 RID: 472
// (get) Token: 0x0600078F RID: 1935 RVA: 0x000179F6 File Offset: 0x00015BF6
internal uint MapTag
{
get
{
return this.mapTag;
}
}
// Token: 0x04000306 RID: 774
private readonly FieldCodec<TKey> keyCodec;
// Token: 0x04000307 RID: 775
private readonly FieldCodec<TValue> valueCodec;
// Token: 0x04000308 RID: 776
private readonly uint mapTag;
// Token: 0x020000DF RID: 223
internal class MessageAdapter : IMessage
{
// Token: 0x170001FD RID: 509
// (get) Token: 0x06000818 RID: 2072 RVA: 0x00018B77 File Offset: 0x00016D77
// (set) Token: 0x06000819 RID: 2073 RVA: 0x00018B7F File Offset: 0x00016D7F
internal TKey Key { get; set; }
// Token: 0x170001FE RID: 510
// (get) Token: 0x0600081A RID: 2074 RVA: 0x00018B88 File Offset: 0x00016D88
// (set) Token: 0x0600081B RID: 2075 RVA: 0x00018B90 File Offset: 0x00016D90
internal TValue Value { get; set; }
// Token: 0x0600081C RID: 2076 RVA: 0x00018B99 File Offset: 0x00016D99
internal MessageAdapter(MapField<TKey, TValue>.Codec codec)
{
this.codec = codec;
}
// Token: 0x0600081D RID: 2077 RVA: 0x00018BA8 File Offset: 0x00016DA8
internal void Reset()
{
this.Key = this.codec.keyCodec.DefaultValue;
this.Value = this.codec.valueCodec.DefaultValue;
}
// Token: 0x0600081E RID: 2078 RVA: 0x00018BD8 File Offset: 0x00016DD8
public void MergeFrom(CodedInputStream input)
{
uint num;
while ((num = input.ReadTag()) != 0U)
{
if (num == this.codec.keyCodec.Tag)
{
this.Key = this.codec.keyCodec.Read(input);
}
else if (num == this.codec.valueCodec.Tag)
{
this.Value = this.codec.valueCodec.Read(input);
}
else
{
input.SkipLastField();
}
}
if (this.Value == null)
{
this.Value = this.codec.valueCodec.Read(new CodedInputStream(MapField<TKey, TValue>.Codec.MessageAdapter.ZeroLengthMessageStreamData));
}
}
// Token: 0x0600081F RID: 2079 RVA: 0x00018C7C File Offset: 0x00016E7C
public void WriteTo(CodedOutputStream output)
{
this.codec.keyCodec.WriteTagAndValue(output, this.Key);
this.codec.valueCodec.WriteTagAndValue(output, this.Value);
}
// Token: 0x06000820 RID: 2080 RVA: 0x00018CAC File Offset: 0x00016EAC
public int CalculateSize()
{
return this.codec.keyCodec.CalculateSizeWithTag(this.Key) + this.codec.valueCodec.CalculateSizeWithTag(this.Value);
}
// Token: 0x170001FF RID: 511
// (get) Token: 0x06000821 RID: 2081 RVA: 0x00018CDB File Offset: 0x00016EDB
MessageDescriptor IMessage.Descriptor
{
get
{
return null;
}
}
// Token: 0x0400038E RID: 910
private static readonly byte[] ZeroLengthMessageStreamData = new byte[1];
// Token: 0x0400038F RID: 911
private readonly MapField<TKey, TValue>.Codec codec;
}
}
// Token: 0x020000CA RID: 202
private class MapView<T> : ICollection<T>, IEnumerable<T>, IEnumerable, ICollection
{
// Token: 0x06000790 RID: 1936 RVA: 0x000179FE File Offset: 0x00015BFE
internal MapView(MapField<TKey, TValue> parent, Func<KeyValuePair<TKey, TValue>, T> projection, Func<T, bool> containsCheck)
{
this.parent = parent;
this.projection = projection;
this.containsCheck = containsCheck;
}
// Token: 0x170001D9 RID: 473
// (get) Token: 0x06000791 RID: 1937 RVA: 0x00017A1B File Offset: 0x00015C1B
public int Count
{
get
{
return this.parent.Count;
}
}
// Token: 0x170001DA RID: 474
// (get) Token: 0x06000792 RID: 1938 RVA: 0x0000324B File Offset: 0x0000144B
public bool IsReadOnly
{
get
{
return true;
}
}
// Token: 0x170001DB RID: 475
// (get) Token: 0x06000793 RID: 1939 RVA: 0x0000761F File Offset: 0x0000581F
public bool IsSynchronized
{
get
{
return false;
}
}
// Token: 0x170001DC RID: 476
// (get) Token: 0x06000794 RID: 1940 RVA: 0x00017A28 File Offset: 0x00015C28
public object SyncRoot
{
get
{
return this.parent;
}
}
// Token: 0x06000795 RID: 1941 RVA: 0x00007624 File Offset: 0x00005824
public void Add(T item)
{
throw new NotSupportedException();
}
// Token: 0x06000796 RID: 1942 RVA: 0x00007624 File Offset: 0x00005824
public void Clear()
{
throw new NotSupportedException();
}
// Token: 0x06000797 RID: 1943 RVA: 0x00017A30 File Offset: 0x00015C30
public bool Contains(T item)
{
return this.containsCheck(item);
}
// Token: 0x06000798 RID: 1944 RVA: 0x00017A40 File Offset: 0x00015C40
public void CopyTo(T[] array, int arrayIndex)
{
if (arrayIndex < 0)
{
throw new ArgumentOutOfRangeException("arrayIndex");
}
if (arrayIndex + this.Count >= array.Length)
{
throw new ArgumentException("Not enough space in the array", "array");
}
foreach (T t in this)
{
array[arrayIndex++] = t;
}
}
// Token: 0x06000799 RID: 1945 RVA: 0x00017ABC File Offset: 0x00015CBC
public IEnumerator<T> GetEnumerator()
{
return this.parent.list.Select(this.projection).GetEnumerator();
}
// Token: 0x0600079A RID: 1946 RVA: 0x00007624 File Offset: 0x00005824
public bool Remove(T item)
{
throw new NotSupportedException();
}
// Token: 0x0600079B RID: 1947 RVA: 0x00017AD9 File Offset: 0x00015CD9
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
// Token: 0x0600079C RID: 1948 RVA: 0x00017AE4 File Offset: 0x00015CE4
public void CopyTo(Array array, int index)
{
if (index < 0)
{
throw new ArgumentOutOfRangeException("index");
}
if (index + this.Count >= array.Length)
{
throw new ArgumentException("Not enough space in the array", "array");
}
foreach (T t in this)
{
array.SetValue(t, index++);
}
}
// Token: 0x04000309 RID: 777
private readonly MapField<TKey, TValue> parent;
// Token: 0x0400030A RID: 778
private readonly Func<KeyValuePair<TKey, TValue>, T> projection;
// Token: 0x0400030B RID: 779
private readonly Func<T, bool> containsCheck;
}
}
}
+156
View File
@@ -0,0 +1,156 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Google.Protobuf.Collections
{
// Token: 0x02000070 RID: 112
internal sealed class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable
{
// Token: 0x06000633 RID: 1587 RVA: 0x00015996 File Offset: 0x00013B96
public ReadOnlyDictionary(IDictionary<TKey, TValue> wrapped)
{
this.wrapped = wrapped;
}
// Token: 0x06000634 RID: 1588 RVA: 0x000159A5 File Offset: 0x00013BA5
public void Add(TKey key, TValue value)
{
throw new InvalidOperationException();
}
// Token: 0x06000635 RID: 1589 RVA: 0x000159AC File Offset: 0x00013BAC
public bool ContainsKey(TKey key)
{
return this.wrapped.ContainsKey(key);
}
// Token: 0x170001C0 RID: 448
// (get) Token: 0x06000636 RID: 1590 RVA: 0x000159BA File Offset: 0x00013BBA
public ICollection<TKey> Keys
{
get
{
return this.wrapped.Keys;
}
}
// Token: 0x06000637 RID: 1591 RVA: 0x000159A5 File Offset: 0x00013BA5
public bool Remove(TKey key)
{
throw new InvalidOperationException();
}
// Token: 0x06000638 RID: 1592 RVA: 0x000159C7 File Offset: 0x00013BC7
public bool TryGetValue(TKey key, out TValue value)
{
return this.wrapped.TryGetValue(key, out value);
}
// Token: 0x170001C1 RID: 449
// (get) Token: 0x06000639 RID: 1593 RVA: 0x000159D6 File Offset: 0x00013BD6
public ICollection<TValue> Values
{
get
{
return this.wrapped.Values;
}
}
// Token: 0x170001C2 RID: 450
public TValue this[TKey key]
{
get
{
return this.wrapped[key];
}
set
{
throw new InvalidOperationException();
}
}
// Token: 0x0600063C RID: 1596 RVA: 0x000159A5 File Offset: 0x00013BA5
public void Add(KeyValuePair<TKey, TValue> item)
{
throw new InvalidOperationException();
}
// Token: 0x0600063D RID: 1597 RVA: 0x000159A5 File Offset: 0x00013BA5
public void Clear()
{
throw new InvalidOperationException();
}
// Token: 0x0600063E RID: 1598 RVA: 0x000159F1 File Offset: 0x00013BF1
public bool Contains(KeyValuePair<TKey, TValue> item)
{
return this.wrapped.Contains(item);
}
// Token: 0x0600063F RID: 1599 RVA: 0x000159FF File Offset: 0x00013BFF
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
{
this.wrapped.CopyTo(array, arrayIndex);
}
// Token: 0x170001C3 RID: 451
// (get) Token: 0x06000640 RID: 1600 RVA: 0x00015A0E File Offset: 0x00013C0E
public int Count
{
get
{
return this.wrapped.Count;
}
}
// Token: 0x170001C4 RID: 452
// (get) Token: 0x06000641 RID: 1601 RVA: 0x0000324B File Offset: 0x0000144B
public bool IsReadOnly
{
get
{
return true;
}
}
// Token: 0x06000642 RID: 1602 RVA: 0x000159A5 File Offset: 0x00013BA5
public bool Remove(KeyValuePair<TKey, TValue> item)
{
throw new InvalidOperationException();
}
// Token: 0x06000643 RID: 1603 RVA: 0x00015A1B File Offset: 0x00013C1B
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return this.wrapped.GetEnumerator();
}
// Token: 0x06000644 RID: 1604 RVA: 0x00015A28 File Offset: 0x00013C28
IEnumerator IEnumerable.GetEnumerator()
{
return this.wrapped.GetEnumerator();
}
// Token: 0x06000645 RID: 1605 RVA: 0x00015A35 File Offset: 0x00013C35
public override bool Equals(object obj)
{
return this.wrapped.Equals(obj);
}
// Token: 0x06000646 RID: 1606 RVA: 0x00015A43 File Offset: 0x00013C43
public override int GetHashCode()
{
return this.wrapped.GetHashCode();
}
// Token: 0x06000647 RID: 1607 RVA: 0x00015A50 File Offset: 0x00013C50
public override string ToString()
{
return this.wrapped.ToString();
}
// Token: 0x04000268 RID: 616
private readonly IDictionary<TKey, TValue> wrapped;
}
}
+480
View File
@@ -0,0 +1,480 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
namespace Google.Protobuf.Collections
{
// Token: 0x02000071 RID: 113
public sealed class RepeatedField<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IList, ICollection, IDeepCloneable<RepeatedField<T>>, IEquatable<RepeatedField<T>>
{
// Token: 0x06000648 RID: 1608 RVA: 0x00015A60 File Offset: 0x00013C60
public RepeatedField<T> Clone()
{
RepeatedField<T> repeatedField = new RepeatedField<T>();
if (this.array != RepeatedField<T>.EmptyArray)
{
repeatedField.array = (T[])this.array.Clone();
IDeepCloneable<T>[] array = repeatedField.array as IDeepCloneable<T>[];
if (array != null)
{
for (int i = 0; i < this.count; i++)
{
repeatedField.array[i] = array[i].Clone();
}
}
}
repeatedField.count = this.count;
return repeatedField;
}
// Token: 0x06000649 RID: 1609 RVA: 0x00015AD8 File Offset: 0x00013CD8
public void AddEntriesFrom(CodedInputStream input, FieldCodec<T> codec)
{
uint lastTag = input.LastTag;
Func<CodedInputStream, T> valueReader = codec.ValueReader;
if (FieldCodec<T>.IsPackedRepeatedField(lastTag))
{
int num = input.ReadLength();
if (num > 0)
{
int num2 = input.PushLimit(num);
while (!input.ReachedLimit)
{
this.Add(valueReader(input));
}
input.PopLimit(num2);
return;
}
}
else
{
do
{
this.Add(valueReader(input));
}
while (input.MaybeConsumeTag(lastTag));
}
}
// Token: 0x0600064A RID: 1610 RVA: 0x00015B44 File Offset: 0x00013D44
public int CalculateSize(FieldCodec<T> codec)
{
if (this.count == 0)
{
return 0;
}
uint tag = codec.Tag;
if (codec.PackedRepeatedField)
{
int num = this.CalculatePackedDataSize(codec);
return CodedOutputStream.ComputeRawVarint32Size(tag) + CodedOutputStream.ComputeLengthSize(num) + num;
}
Func<T, int> valueSizeCalculator = codec.ValueSizeCalculator;
int num2 = this.count * CodedOutputStream.ComputeRawVarint32Size(tag);
for (int i = 0; i < this.count; i++)
{
num2 += valueSizeCalculator(this.array[i]);
}
return num2;
}
// Token: 0x0600064B RID: 1611 RVA: 0x00015BC4 File Offset: 0x00013DC4
private int CalculatePackedDataSize(FieldCodec<T> codec)
{
int fixedSize = codec.FixedSize;
if (fixedSize == 0)
{
Func<T, int> valueSizeCalculator = codec.ValueSizeCalculator;
int num = 0;
for (int i = 0; i < this.count; i++)
{
num += valueSizeCalculator(this.array[i]);
}
return num;
}
return fixedSize * this.Count;
}
// Token: 0x0600064C RID: 1612 RVA: 0x00015C14 File Offset: 0x00013E14
public void WriteTo(CodedOutputStream output, FieldCodec<T> codec)
{
if (this.count == 0)
{
return;
}
Action<CodedOutputStream, T> valueWriter = codec.ValueWriter;
uint tag = codec.Tag;
if (codec.PackedRepeatedField)
{
uint num = (uint)this.CalculatePackedDataSize(codec);
output.WriteTag(tag);
output.WriteRawVarint32(num);
for (int i = 0; i < this.count; i++)
{
valueWriter(output, this.array[i]);
}
return;
}
for (int j = 0; j < this.count; j++)
{
output.WriteTag(tag);
valueWriter(output, this.array[j]);
}
}
// Token: 0x0600064D RID: 1613 RVA: 0x00015CAC File Offset: 0x00013EAC
private void EnsureSize(int size)
{
if (this.array.Length < size)
{
size = Math.Max(size, 8);
T[] array = new T[Math.Max(this.array.Length * 2, size)];
Array.Copy(this.array, 0, array, 0, this.array.Length);
this.array = array;
}
}
// Token: 0x0600064E RID: 1614 RVA: 0x00015D00 File Offset: 0x00013F00
public void Add(T item)
{
ProtoPreconditions.CheckNotNullUnconstrained<T>(item, "item");
this.EnsureSize(this.count + 1);
T[] array = this.array;
int num = this.count;
this.count = num + 1;
array[num] = item;
}
// Token: 0x0600064F RID: 1615 RVA: 0x00015D44 File Offset: 0x00013F44
public void Clear()
{
this.array = RepeatedField<T>.EmptyArray;
this.count = 0;
}
// Token: 0x06000650 RID: 1616 RVA: 0x00015D58 File Offset: 0x00013F58
public bool Contains(T item)
{
return this.IndexOf(item) != -1;
}
// Token: 0x06000651 RID: 1617 RVA: 0x00015D67 File Offset: 0x00013F67
public void CopyTo(T[] array, int arrayIndex)
{
Array.Copy(this.array, 0, array, arrayIndex, this.count);
}
// Token: 0x06000652 RID: 1618 RVA: 0x00015D80 File Offset: 0x00013F80
public bool Remove(T item)
{
int num = this.IndexOf(item);
if (num == -1)
{
return false;
}
Array.Copy(this.array, num + 1, this.array, num, this.count - num - 1);
this.count--;
this.array[this.count] = default(T);
return true;
}
// Token: 0x170001C5 RID: 453
// (get) Token: 0x06000653 RID: 1619 RVA: 0x00015DE3 File Offset: 0x00013FE3
public int Count
{
get
{
return this.count;
}
}
// Token: 0x170001C6 RID: 454
// (get) Token: 0x06000654 RID: 1620 RVA: 0x0000761F File Offset: 0x0000581F
public bool IsReadOnly
{
get
{
return false;
}
}
// Token: 0x06000655 RID: 1621 RVA: 0x00015DEC File Offset: 0x00013FEC
public void AddRange(IEnumerable<T> values)
{
ProtoPreconditions.CheckNotNull<IEnumerable<T>>(values, "values");
RepeatedField<T> repeatedField = values as RepeatedField<T>;
if (repeatedField != null)
{
this.EnsureSize(this.count + repeatedField.count);
Array.Copy(repeatedField.array, 0, this.array, this.count, repeatedField.count);
this.count += repeatedField.count;
return;
}
ICollection collection = values as ICollection;
if (collection != null)
{
int num = collection.Count;
if (default(T) == null)
{
using (IEnumerator enumerator = collection.GetEnumerator())
{
while (enumerator.MoveNext())
{
if (enumerator.Current == null)
{
throw new ArgumentException("Sequence contained null element", "values");
}
}
}
}
this.EnsureSize(this.count + num);
collection.CopyTo(this.array, this.count);
this.count += num;
return;
}
foreach (T t in values)
{
this.Add(t);
}
}
// Token: 0x06000656 RID: 1622 RVA: 0x00015F38 File Offset: 0x00014138
public void Add(IEnumerable<T> values)
{
this.AddRange(values);
}
// Token: 0x06000657 RID: 1623 RVA: 0x00015F41 File Offset: 0x00014141
public IEnumerator<T> GetEnumerator()
{
int num;
for (int i = 0; i < this.count; i = num + 1)
{
yield return this.array[i];
num = i;
}
yield break;
}
// Token: 0x06000658 RID: 1624 RVA: 0x00015F50 File Offset: 0x00014150
public override bool Equals(object obj)
{
return this.Equals(obj as RepeatedField<T>);
}
// Token: 0x06000659 RID: 1625 RVA: 0x00015F5E File Offset: 0x0001415E
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
// Token: 0x0600065A RID: 1626 RVA: 0x00015F68 File Offset: 0x00014168
public override int GetHashCode()
{
int num = 0;
for (int i = 0; i < this.count; i++)
{
num = num * 31 + this.array[i].GetHashCode();
}
return num;
}
// Token: 0x0600065B RID: 1627 RVA: 0x00015FA8 File Offset: 0x000141A8
public bool Equals(RepeatedField<T> other)
{
if (other == null)
{
return false;
}
if (other == this)
{
return true;
}
if (other.Count != this.Count)
{
return false;
}
EqualityComparer<T> @default = EqualityComparer<T>.Default;
for (int i = 0; i < this.count; i++)
{
if (!@default.Equals(this.array[i], other.array[i]))
{
return false;
}
}
return true;
}
// Token: 0x0600065C RID: 1628 RVA: 0x0001600C File Offset: 0x0001420C
public int IndexOf(T item)
{
ProtoPreconditions.CheckNotNullUnconstrained<T>(item, "item");
EqualityComparer<T> @default = EqualityComparer<T>.Default;
for (int i = 0; i < this.count; i++)
{
if (@default.Equals(this.array[i], item))
{
return i;
}
}
return -1;
}
// Token: 0x0600065D RID: 1629 RVA: 0x00016054 File Offset: 0x00014254
public void Insert(int index, T item)
{
ProtoPreconditions.CheckNotNullUnconstrained<T>(item, "item");
if (index < 0 || index > this.count)
{
throw new ArgumentOutOfRangeException("index");
}
this.EnsureSize(this.count + 1);
Array.Copy(this.array, index, this.array, index + 1, this.count - index);
this.array[index] = item;
this.count++;
}
// Token: 0x0600065E RID: 1630 RVA: 0x000160CC File Offset: 0x000142CC
public void RemoveAt(int index)
{
if (index < 0 || index >= this.count)
{
throw new ArgumentOutOfRangeException("index");
}
Array.Copy(this.array, index + 1, this.array, index, this.count - index - 1);
this.count--;
this.array[this.count] = default(T);
}
// Token: 0x0600065F RID: 1631 RVA: 0x00016138 File Offset: 0x00014338
public override string ToString()
{
StringWriter stringWriter = new StringWriter();
JsonFormatter.Default.WriteList(stringWriter, this);
return stringWriter.ToString();
}
// Token: 0x170001C7 RID: 455
public T this[int index]
{
get
{
if (index < 0 || index >= this.count)
{
throw new ArgumentOutOfRangeException("index");
}
return this.array[index];
}
set
{
if (index < 0 || index >= this.count)
{
throw new ArgumentOutOfRangeException("index");
}
ProtoPreconditions.CheckNotNullUnconstrained<T>(value, "value");
this.array[index] = value;
}
}
// Token: 0x170001C8 RID: 456
// (get) Token: 0x06000662 RID: 1634 RVA: 0x0000761F File Offset: 0x0000581F
bool IList.IsFixedSize
{
get
{
return false;
}
}
// Token: 0x06000663 RID: 1635 RVA: 0x00015D67 File Offset: 0x00013F67
void ICollection.CopyTo(Array array, int index)
{
Array.Copy(this.array, 0, array, index, this.count);
}
// Token: 0x170001C9 RID: 457
// (get) Token: 0x06000664 RID: 1636 RVA: 0x0000761F File Offset: 0x0000581F
bool ICollection.IsSynchronized
{
get
{
return false;
}
}
// Token: 0x170001CA RID: 458
// (get) Token: 0x06000665 RID: 1637 RVA: 0x000142A1 File Offset: 0x000124A1
object ICollection.SyncRoot
{
get
{
return this;
}
}
// Token: 0x170001CB RID: 459
object IList.this[int index]
{
get
{
return this[index];
}
set
{
this[index] = (T)((object)value);
}
}
// Token: 0x06000668 RID: 1640 RVA: 0x000161D3 File Offset: 0x000143D3
int IList.Add(object value)
{
this.Add((T)((object)value));
return this.count - 1;
}
// Token: 0x06000669 RID: 1641 RVA: 0x000161E9 File Offset: 0x000143E9
bool IList.Contains(object value)
{
return value is T && this.Contains((T)((object)value));
}
// Token: 0x0600066A RID: 1642 RVA: 0x00016201 File Offset: 0x00014401
int IList.IndexOf(object value)
{
if (!(value is T))
{
return -1;
}
return this.IndexOf((T)((object)value));
}
// Token: 0x0600066B RID: 1643 RVA: 0x00016219 File Offset: 0x00014419
void IList.Insert(int index, object value)
{
this.Insert(index, (T)((object)value));
}
// Token: 0x0600066C RID: 1644 RVA: 0x00016228 File Offset: 0x00014428
void IList.Remove(object value)
{
if (!(value is T))
{
return;
}
this.Remove((T)((object)value));
}
// Token: 0x04000269 RID: 617
private static readonly T[] EmptyArray = new T[0];
// Token: 0x0400026A RID: 618
private const int MinArraySize = 8;
// Token: 0x0400026B RID: 619
private T[] array = RepeatedField<T>.EmptyArray;
// Token: 0x0400026C RID: 620
private int count;
}
}