jellyfin/Emby.Server.Implementations/IO/SharpCifs/Util/Sharpen/SynchronizedList.cs

107 lines
1.5 KiB
C#
Raw Normal View History

2017-04-02 00:36:06 +00:00
using System.Collections;
using System.Collections.Generic;
namespace SharpCifs.Util.Sharpen
{
internal class SynchronizedList<T> : IList<T>
2017-07-08 03:12:21 +00:00
{
private IList<T> _list;
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
public SynchronizedList (IList<T> list)
{
this._list = list;
}
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
public int IndexOf (T item)
{
lock (_list) {
return _list.IndexOf (item);
}
}
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
public void Insert (int index, T item)
{
lock (_list) {
_list.Insert (index, item);
}
}
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
public void RemoveAt (int index)
{
lock (_list) {
_list.RemoveAt (index);
}
}
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
void ICollection<T>.Add (T item)
{
lock (_list) {
_list.Add (item);
}
}
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
void ICollection<T>.Clear ()
{
lock (_list) {
_list.Clear ();
}
}
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
bool ICollection<T>.Contains (T item)
{
lock (_list) {
return _list.Contains (item);
}
}
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
void ICollection<T>.CopyTo (T[] array, int arrayIndex)
{
lock (_list) {
_list.CopyTo (array, arrayIndex);
}
}
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
bool ICollection<T>.Remove (T item)
{
lock (_list) {
return _list.Remove (item);
}
}
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
IEnumerator<T> IEnumerable<T>.GetEnumerator ()
{
return _list.GetEnumerator ();
}
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
IEnumerator IEnumerable.GetEnumerator ()
{
return _list.GetEnumerator ();
}
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
public T this[int index] {
get {
lock (_list) {
return _list[index];
}
}
set {
lock (_list) {
_list[index] = value;
}
}
}
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
int ICollection<T>.Count {
get {
lock (_list) {
return _list.Count;
}
}
}
2017-04-02 00:36:06 +00:00
2017-07-08 03:12:21 +00:00
bool ICollection<T>.IsReadOnly {
get { return _list.IsReadOnly; }
}
}
2017-04-02 00:36:06 +00:00
}