aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/IO/SharpCifs/Util/Sharpen/SynchronizedList.cs
blob: c105a8bab602be17bdd2db0c56fd698eb6b7618b (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System.Collections;
using System.Collections.Generic;

namespace SharpCifs.Util.Sharpen
{
    internal class SynchronizedList<T> : IList<T>
	{
		private IList<T> _list;

		public SynchronizedList (IList<T> list)
		{
			this._list = list;
		}

		public int IndexOf (T item)
		{
			lock (_list) {
				return _list.IndexOf (item);
			}
		}

		public void Insert (int index, T item)
		{
			lock (_list) {
				_list.Insert (index, item);
			}
		}

		public void RemoveAt (int index)
		{
			lock (_list) {
				_list.RemoveAt (index);
			}
		}

		void ICollection<T>.Add (T item)
		{
			lock (_list) {
				_list.Add (item);
			}
		}

		void ICollection<T>.Clear ()
		{
			lock (_list) {
				_list.Clear ();
			}
		}

		bool ICollection<T>.Contains (T item)
		{
			lock (_list) {
				return _list.Contains (item);
			}
		}

		void ICollection<T>.CopyTo (T[] array, int arrayIndex)
		{
			lock (_list) {
				_list.CopyTo (array, arrayIndex);
			}
		}

		bool ICollection<T>.Remove (T item)
		{
			lock (_list) {
				return _list.Remove (item);
			}
		}

		IEnumerator<T> IEnumerable<T>.GetEnumerator ()
		{
			return _list.GetEnumerator ();
		}

		IEnumerator IEnumerable.GetEnumerator ()
		{
			return _list.GetEnumerator ();
		}

		public T this[int index] {
			get {
				lock (_list) {
					return _list[index];
				}
			}
			set {
				lock (_list) {
					_list[index] = value;
				}
			}
		}

		int ICollection<T>.Count {
			get {
				lock (_list) {
					return _list.Count;
				}
			}
		}

		bool ICollection<T>.IsReadOnly {
			get { return _list.IsReadOnly; }
		}
	}
}