瀏覽代碼

Clean up Grouping.

Bart De Smet 7 年之前
父節點
當前提交
67cb696b45

+ 1 - 0
Ix.NET/Source/System.Linq.Async/System/Error.cs

@@ -10,5 +10,6 @@ namespace System
         public static Exception ArgumentOutOfRange(string paramName) => new ArgumentOutOfRangeException(paramName);
         public static Exception NoElements() => new InvalidOperationException(Strings.NO_ELEMENTS);
         public static Exception MoreThanOneElement() => new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
+        public static Exception NotSupported() => new NotSupportedException(Strings.NOT_SUPPORTED);
     }
 }

+ 6 - 21
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs

@@ -39,36 +39,21 @@ namespace System.Linq.Internal
 
         bool ICollection<TElement>.IsReadOnly => true;
 
-        void ICollection<TElement>.Add(TElement item)
-        {
-            throw new NotSupportedException(Strings.NOT_SUPPORTED);
-        }
+        void ICollection<TElement>.Add(TElement item) => throw Error.NotSupported();
 
-        void ICollection<TElement>.Clear()
-        {
-            throw new NotSupportedException(Strings.NOT_SUPPORTED);
-        }
+        void ICollection<TElement>.Clear() => throw Error.NotSupported();
 
         bool ICollection<TElement>.Contains(TElement item) => Array.IndexOf(_elements, item, 0, _count) >= 0;
 
         void ICollection<TElement>.CopyTo(TElement[] array, int arrayIndex) => Array.Copy(_elements, 0, array, arrayIndex, _count);
 
-        bool ICollection<TElement>.Remove(TElement item)
-        {
-            throw new NotSupportedException(Strings.NOT_SUPPORTED);
-        }
+        bool ICollection<TElement>.Remove(TElement item) => throw Error.NotSupported();
 
         int IList<TElement>.IndexOf(TElement item) => Array.IndexOf(_elements, item, 0, _count);
 
-        void IList<TElement>.Insert(int index, TElement item)
-        {
-            throw new NotSupportedException(Strings.NOT_SUPPORTED);
-        }
+        void IList<TElement>.Insert(int index, TElement item) => throw Error.NotSupported();
 
-        void IList<TElement>.RemoveAt(int index)
-        {
-            throw new NotSupportedException(Strings.NOT_SUPPORTED);
-        }
+        void IList<TElement>.RemoveAt(int index) => throw Error.NotSupported();
 
         TElement IList<TElement>.this[int index]
         {
@@ -82,7 +67,7 @@ namespace System.Linq.Internal
                 return _elements[index];
             }
 
-            set { throw new NotSupportedException(Strings.NOT_SUPPORTED); }
+            set => throw Error.NotSupported();
         }
 
         internal void Add(TElement element)