From 23691e181b122dd345e2878556662a3d31266cee Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 21 Jun 2017 02:46:57 -0400 Subject: update sharpcifs --- .../IO/SharpCifs/Util/Sharpen/AbstractMap.cs | 297 +++++++++++---------- 1 file changed, 155 insertions(+), 142 deletions(-) (limited to 'Emby.Common.Implementations/IO/SharpCifs/Util/Sharpen/AbstractMap.cs') diff --git a/Emby.Common.Implementations/IO/SharpCifs/Util/Sharpen/AbstractMap.cs b/Emby.Common.Implementations/IO/SharpCifs/Util/Sharpen/AbstractMap.cs index 2868a840ad..45e7e21449 100644 --- a/Emby.Common.Implementations/IO/SharpCifs/Util/Sharpen/AbstractMap.cs +++ b/Emby.Common.Implementations/IO/SharpCifs/Util/Sharpen/AbstractMap.cs @@ -6,146 +6,159 @@ using System.Linq; namespace SharpCifs.Util.Sharpen { public abstract class AbstractMap : IDictionary - { - public virtual void Clear () - { - EntrySet ().Clear (); - } - - public virtual bool ContainsKey (object name) - { - return EntrySet ().Any (p => p.Key.Equals ((T)name)); - } - - public abstract ICollection> EntrySet (); - - public virtual TU Get (object key) - { - return EntrySet ().Where (p => p.Key.Equals (key)).Select (p => p.Value).FirstOrDefault (); - } - - protected virtual IEnumerator> InternalGetEnumerator () - { - return EntrySet ().GetEnumerator (); - } - - public virtual bool IsEmpty () - { - return !EntrySet ().Any (); - } - - public virtual TU Put (T key, TU value) - { - throw new NotSupportedException (); - } - - public virtual TU Remove (object key) - { - Iterator iterator = EntrySet () as Iterator; - if (iterator == null) { - throw new NotSupportedException (); - } - while (iterator.HasNext ()) { - TU local = iterator.Next (); - if (local.Equals ((T)key)) { - iterator.Remove (); - return local; - } - } - return default(TU); - } - - void ICollection>.Add (KeyValuePair item) - { - Put (item.Key, item.Value); - } - - bool ICollection>.Contains (KeyValuePair item) - { - throw new NotImplementedException (); - } - - void ICollection>.CopyTo (KeyValuePair[] array, int arrayIndex) - { - EntrySet ().CopyTo (array, arrayIndex); - } - - bool ICollection>.Remove (KeyValuePair item) - { - Remove (item.Key); - return true; - } - - void IDictionary.Add (T key, TU value) - { - Put (key, value); - } - - bool IDictionary.ContainsKey (T key) - { - return ContainsKey (key); - } - - bool IDictionary.Remove (T key) - { - if (ContainsKey (key)) { - Remove (key); - return true; - } - return false; - } - - bool IDictionary.TryGetValue (T key, out TU value) - { - if (ContainsKey (key)) { - value = Get (key); - return true; - } - value = default(TU); - return false; - } - - IEnumerator> IEnumerable>.GetEnumerator () - { - return InternalGetEnumerator (); - } - - IEnumerator IEnumerable.GetEnumerator () - { - return InternalGetEnumerator (); - } - - public virtual int Count { - get { return EntrySet ().Count; } - } - - public TU this[T key] { - get { return Get (key); } - set { Put (key, value); } - } - - public virtual IEnumerable Keys { - get { return EntrySet ().Select (p => p.Key); } - } - - int ICollection>.Count { - get { return Count; } - } - - bool ICollection>.IsReadOnly { - get { return false; } - } - - ICollection IDictionary.Keys { - get { return Keys.ToList (); } - } - - ICollection IDictionary.Values { - get { return Values.ToList (); } - } - - public virtual IEnumerable Values { - get { return EntrySet ().Select (p => p.Value); } - } - } + { + public virtual void Clear() + { + EntrySet().Clear(); + } + + public virtual bool ContainsKey(object name) + { + return EntrySet().Any(p => p.Key.Equals((T)name)); + } + + public abstract ICollection> EntrySet(); + + public virtual TU Get(object key) + { + return EntrySet().Where(p => p.Key.Equals(key)).Select(p => p.Value).FirstOrDefault(); + } + + protected virtual IEnumerator> InternalGetEnumerator() + { + return EntrySet().GetEnumerator(); + } + + public virtual bool IsEmpty() + { + return !EntrySet().Any(); + } + + public virtual TU Put(T key, TU value) + { + throw new NotSupportedException(); + } + + public virtual TU Remove(object key) + { + Iterator iterator = EntrySet() as Iterator; + if (iterator == null) + { + throw new NotSupportedException(); + } + while (iterator.HasNext()) + { + TU local = iterator.Next(); + if (local.Equals((T)key)) + { + iterator.Remove(); + return local; + } + } + return default(TU); + } + + void ICollection>.Add(KeyValuePair item) + { + Put(item.Key, item.Value); + } + + bool ICollection>.Contains(KeyValuePair item) + { + throw new NotImplementedException(); + } + + void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) + { + EntrySet().CopyTo(array, arrayIndex); + } + + bool ICollection>.Remove(KeyValuePair item) + { + Remove(item.Key); + return true; + } + + void IDictionary.Add(T key, TU value) + { + Put(key, value); + } + + bool IDictionary.ContainsKey(T key) + { + return ContainsKey(key); + } + + bool IDictionary.Remove(T key) + { + if (ContainsKey(key)) + { + Remove(key); + return true; + } + return false; + } + + bool IDictionary.TryGetValue(T key, out TU value) + { + if (ContainsKey(key)) + { + value = Get(key); + return true; + } + value = default(TU); + return false; + } + + IEnumerator> IEnumerable>.GetEnumerator() + { + return InternalGetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return InternalGetEnumerator(); + } + + public virtual int Count + { + get { return EntrySet().Count; } + } + + public TU this[T key] + { + get { return Get(key); } + set { Put(key, value); } + } + + public virtual IEnumerable Keys + { + get { return EntrySet().Select(p => p.Key); } + } + + int ICollection>.Count + { + get { return Count; } + } + + bool ICollection>.IsReadOnly + { + get { return false; } + } + + ICollection IDictionary.Keys + { + get { return Keys.ToList(); } + } + + ICollection IDictionary.Values + { + get { return Values.ToList(); } + } + + public virtual IEnumerable Values + { + get { return EntrySet().Select(p => p.Value); } + } + } } -- cgit v1.2.3