mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 19:10:32 +00:00
style(SyncDictionary): code formatting
This commit is contained in:
parent
ea01b7c060
commit
0b8b11e78f
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
@ -5,13 +6,12 @@ namespace Mirror
|
|||||||
{
|
{
|
||||||
public class SyncIDictionary<TKey, TValue> : SyncObject, IDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>
|
public class SyncIDictionary<TKey, TValue> : SyncObject, IDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>
|
||||||
{
|
{
|
||||||
public delegate void SyncDictionaryChanged(Operation op, TKey key, TValue item);
|
public Action<Operation, TKey, TValue> Callback;
|
||||||
|
|
||||||
protected readonly IDictionary<TKey, TValue> objects;
|
protected readonly IDictionary<TKey, TValue> objects;
|
||||||
|
|
||||||
public int Count => objects.Count;
|
public int Count => objects.Count;
|
||||||
public bool IsReadOnly => !IsWritable();
|
public bool IsReadOnly => !IsWritable();
|
||||||
public event SyncDictionaryChanged Callback;
|
|
||||||
|
|
||||||
public enum Operation : byte
|
public enum Operation : byte
|
||||||
{
|
{
|
||||||
@ -275,21 +275,15 @@ public void Add(TKey key, TValue value)
|
|||||||
|
|
||||||
public void Add(KeyValuePair<TKey, TValue> item) => Add(item.Key, item.Value);
|
public void Add(KeyValuePair<TKey, TValue> item) => Add(item.Key, item.Value);
|
||||||
|
|
||||||
public bool Contains(KeyValuePair<TKey, TValue> item)
|
public bool Contains(KeyValuePair<TKey, TValue> item) => TryGetValue(item.Key, out TValue val) && EqualityComparer<TValue>.Default.Equals(val, item.Value);
|
||||||
{
|
|
||||||
return TryGetValue(item.Key, out TValue val) && EqualityComparer<TValue>.Default.Equals(val, item.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
|
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
|
||||||
{
|
{
|
||||||
if (arrayIndex < 0 || arrayIndex > array.Length)
|
if (arrayIndex < 0 || arrayIndex > array.Length)
|
||||||
{
|
|
||||||
throw new System.ArgumentOutOfRangeException(nameof(arrayIndex), "Array Index Out of Range");
|
throw new System.ArgumentOutOfRangeException(nameof(arrayIndex), "Array Index Out of Range");
|
||||||
}
|
|
||||||
if (array.Length - arrayIndex < Count)
|
if (array.Length - arrayIndex < Count)
|
||||||
{
|
|
||||||
throw new System.ArgumentException("The number of items in the SyncDictionary is greater than the available space from arrayIndex to the end of the destination array");
|
throw new System.ArgumentException("The number of items in the SyncDictionary is greater than the available space from arrayIndex to the end of the destination array");
|
||||||
}
|
|
||||||
|
|
||||||
int i = arrayIndex;
|
int i = arrayIndex;
|
||||||
foreach (KeyValuePair<TKey, TValue> item in objects)
|
foreach (KeyValuePair<TKey, TValue> item in objects)
|
||||||
@ -303,9 +297,8 @@ public bool Remove(KeyValuePair<TKey, TValue> item)
|
|||||||
{
|
{
|
||||||
bool result = objects.Remove(item.Key);
|
bool result = objects.Remove(item.Key);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
|
||||||
AddOperation(Operation.OP_REMOVE, item.Key, item.Value, true);
|
AddOperation(Operation.OP_REMOVE, item.Key, item.Value, true);
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user