Răsfoiți Sursa

Refactoring some files.

Bart De Smet 8 ani în urmă
părinte
comite
d4aa15bcb2

+ 0 - 8
Ix.NET/Source/System.Interactive/System/Linq/IAwaitable.cs

@@ -2,18 +2,10 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System.Runtime.CompilerServices;
-
 namespace System.Linq
 {
     public interface IAwaitable
     {
         IAwaiter GetAwaiter();
     }
-
-    public interface IAwaiter : ICriticalNotifyCompletion
-    {
-        bool IsCompleted { get; }
-        void GetResult();
-    }
 }

+ 14 - 0
Ix.NET/Source/System.Interactive/System/Linq/IAwaiter.cs

@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information. 
+
+using System.Runtime.CompilerServices;
+
+namespace System.Linq
+{
+    public interface IAwaiter : ICriticalNotifyCompletion
+    {
+        bool IsCompleted { get; }
+        void GetResult();
+    }
+}

+ 0 - 71
Ix.NET/Source/System.Interactive/System/Linq/IYielder.cs

@@ -25,75 +25,4 @@ namespace System.Linq
         /// <returns>Awaitable object for use in an asynchronous method.</returns>
         IAwaitable Return(T value);
     }
-
-    internal sealed class Yielder<T> : IYielder<T>, IAwaitable, IAwaiter
-    {
-        private readonly Action<Yielder<T>> _create;
-        private Action _continuation;
-        private bool _hasValue;
-        private bool _running;
-        private bool _stopped;
-
-        public Yielder(Action<Yielder<T>> create)
-        {
-            _create = create;
-        }
-
-        public T Current { get; private set; }
-
-        public IAwaiter GetAwaiter() => this;
-
-        public bool IsCompleted => false;
-
-        public void GetResult()
-        {
-        }
-
-        [SecurityCritical]
-        public void UnsafeOnCompleted(Action continuation)
-        {
-            _continuation = continuation;
-        }
-
-        public void OnCompleted(Action continuation)
-        {
-            _continuation = continuation;
-        }
-
-        public IAwaitable Return(T value)
-        {
-            _hasValue = true;
-            Current = value;
-            return this;
-        }
-
-        public IAwaitable Break()
-        {
-            _stopped = true;
-            return this;
-        }
-
-        public Yielder<T> GetEnumerator() => this;
-
-        public bool MoveNext()
-        {
-            if (!_running)
-            {
-                _running = true;
-                _create(this);
-            }
-            else
-            {
-                _hasValue = false;
-                _continuation();
-            }
-
-            return !_stopped && _hasValue;
-        }
-
-        public void Reset()
-        {
-            throw new NotSupportedException();
-        }
-    }
 }

+ 79 - 0
Ix.NET/Source/System.Interactive/System/Linq/Yielder.cs

@@ -0,0 +1,79 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information. 
+
+using System.Security;
+
+namespace System.Linq
+{
+    internal sealed class Yielder<T> : IYielder<T>, IAwaitable, IAwaiter
+    {
+        private readonly Action<Yielder<T>> _create;
+        private Action _continuation;
+        private bool _hasValue;
+        private bool _running;
+        private bool _stopped;
+
+        public Yielder(Action<Yielder<T>> create)
+        {
+            _create = create;
+        }
+
+        public T Current { get; private set; }
+
+        public IAwaiter GetAwaiter() => this;
+
+        public bool IsCompleted => false;
+
+        public void GetResult()
+        {
+        }
+
+        [SecurityCritical]
+        public void UnsafeOnCompleted(Action continuation)
+        {
+            _continuation = continuation;
+        }
+
+        public void OnCompleted(Action continuation)
+        {
+            _continuation = continuation;
+        }
+
+        public IAwaitable Return(T value)
+        {
+            _hasValue = true;
+            Current = value;
+            return this;
+        }
+
+        public IAwaitable Break()
+        {
+            _stopped = true;
+            return this;
+        }
+
+        public Yielder<T> GetEnumerator() => this;
+
+        public bool MoveNext()
+        {
+            if (!_running)
+            {
+                _running = true;
+                _create(this);
+            }
+            else
+            {
+                _hasValue = false;
+                _continuation();
+            }
+
+            return !_stopped && _hasValue;
+        }
+
+        public void Reset()
+        {
+            throw new NotSupportedException();
+        }
+    }
+}