Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive.Concurrency
{
/// <summary>
/// Represents a work item that has been scheduled.
/// </summary>
/// <typeparam name="TAbsolute">Absolute time representation type.</typeparam>
public interface IScheduledItem<TAbsolute>
{
/// <summary>
/// Gets the absolute time at which the item is due for invocation.
/// </summary>
TAbsolute DueTime { get; }
/// <summary>
/// Invokes the work item.
/// </summary>
void Invoke();
}
}

View File

@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive.Concurrency
{
/// <summary>
/// Represents an object that schedules units of work.
/// </summary>
public interface IScheduler
{
/// <summary>
/// Gets the scheduler's notion of current time.
/// </summary>
DateTimeOffset Now { get; }
/// <summary>
/// Schedules an action to be executed.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
/// <param name="state">State passed to the action to be executed.</param>
/// <param name="action">Action to be executed.</param>
/// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action);
/// <summary>
/// Schedules an action to be executed after dueTime.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
/// <param name="state">State passed to the action to be executed.</param>
/// <param name="action">Action to be executed.</param>
/// <param name="dueTime">Relative time after which to execute the action.</param>
/// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action);
/// <summary>
/// Schedules an action to be executed at dueTime.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
/// <param name="state">State passed to the action to be executed.</param>
/// <param name="action">Action to be executed.</param>
/// <param name="dueTime">Absolute time at which to execute the action.</param>
/// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
IDisposable Schedule<TState>(TState state, DateTimeOffset dueTime, Func<IScheduler, TState, IDisposable> action);
}
}

View File

@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Reactive.Disposables;
namespace System.Reactive.Concurrency
{
/// <summary>
/// Scheduler with support for starting long-running tasks.
/// This type of scheduler can be used to run loops more efficiently instead of using recursive scheduling.
/// </summary>
public interface ISchedulerLongRunning
{
/// <summary>
/// Schedules a long-running piece of work.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
/// <param name="state">State passed to the action to be executed.</param>
/// <param name="action">Action to be executed.</param>
/// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
/// <remarks>
/// <para><b>Notes to implementers</b></para>
/// The returned disposable object should not prevent the work from starting, but only set the cancellation flag passed to the specified action.
/// </remarks>
IDisposable ScheduleLongRunning<TState>(TState state, Action<TState, ICancelable> action);
}
}

View File

@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Reactive.Disposables;
namespace System.Reactive.Concurrency
{
/// <summary>
/// Scheduler with support for running periodic tasks.
/// This type of scheduler can be used to run timers more efficiently instead of using recursive scheduling.
/// </summary>
public interface ISchedulerPeriodic
{
/// <summary>
/// Schedules a periodic piece of work.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
/// <param name="state">Initial state passed to the action upon the first iteration.</param>
/// <param name="period">Period for running the work periodically.</param>
/// <param name="action">Action to be executed, potentially updating the state.</param>
/// <returns>The disposable object used to cancel the scheduled recurring action (best effort).</returns>
IDisposable SchedulePeriodic<TState>(TState state, TimeSpan period, Func<TState, TState> action);
}
}

View File

@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
namespace System.Reactive.Concurrency
{
/// <summary>
/// Abstraction for a stopwatch to compute time relative to a starting point.
/// </summary>
public interface IStopwatch
{
/// <summary>
/// Gets the time elapsed since the stopwatch object was obtained.
/// </summary>
TimeSpan Elapsed { get; }
}
}

View File

@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
namespace System.Reactive.Concurrency
{
/*
* The ability to request a stopwatch object has been introduced in Rx v2.0 to reduce the
* number of allocations made by operators that use absolute time to compute relative time
* diffs, such as TimeInterval and Delay. This causes a large number of related objects to
* be allocated in the BCL, e.g. System.Globalization.DaylightTime.
*/
/// <summary>
/// Provider for IStopwatch objects.
/// </summary>
public interface IStopwatchProvider
{
/// <summary>
/// Starts a new stopwatch object.
/// </summary>
/// <returns>New stopwatch object; started at the time of the request.</returns>
IStopwatch StartStopwatch();
}
}

View File

@@ -0,0 +1,15 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive.Disposables
{
/// <summary>
/// Disposable resource with dipsosal state tracking.
/// </summary>
public interface ICancelable : IDisposable
{
/// <summary>
/// Gets a value that indicates whether the object is disposed.
/// </summary>
bool IsDisposed { get; }
}
}

View File

@@ -0,0 +1,37 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive
{
/// <summary>
/// Represents a .NET event invocation consisting of the strongly typed object that raised the event and the data that was generated by the event.
/// </summary>
/// <typeparam name="TSender">
/// The type of the sender that raised the event.
/// This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
/// <typeparam name="TEventArgs">
/// The type of the event data generated by the event.
/// This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
public interface IEventPattern<
#if !NO_VARIANCE
out TSender, out TEventArgs
#else
TSender, TEventArgs
#endif
>
#if !NO_EVENTARGS_CONSTRAINT
where TEventArgs : EventArgs
#endif
{
/// <summary>
/// Gets the sender object that raised the event.
/// </summary>
TSender Sender { get; }
/// <summary>
/// Gets the event data that was generated by the event.
/// </summary>
TEventArgs EventArgs { get; }
}
}

View File

@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive
{
/// <summary>
/// Represents a data stream signaling its elements by means of an event.
/// </summary>
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
public interface IEventPatternSource<TEventArgs>
#if !NO_EVENTARGS_CONSTRAINT
where TEventArgs : EventArgs
#endif
{
/// <summary>
/// Event signaling the next element in the data stream.
/// </summary>
event EventHandler<TEventArgs> OnNext;
}
}

View File

@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive
{
/// <summary>
/// Represents a data stream signaling its elements by means of an event.
/// </summary>
/// <typeparam name="T">
/// The type of the event data generated by the event.
/// This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
public interface IEventSource<
#if !NO_VARIANCE && !SILVERLIGHT4 // SL4 doesn't mark Action<T> as contravariant!
out
#endif
T>
{
/// <summary>
/// Event signaling the next element in the data stream.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "By design.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1009:DeclareEventHandlersCorrectly", Justification = "Can't do this for Action<T>.")]
event Action<T> OnNext;
}
}

View File

@@ -0,0 +1,42 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive
{
/// <summary>
/// Provides a mechanism for receiving push-based notifications and returning a response.
/// </summary>
/// <typeparam name="TValue">
/// The type of the elements received by the observer.
/// This type parameter is contravariant. That is, you can use either the type you specified or any type that is less derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
/// <typeparam name="TResult">
/// The type of the result returned from the observer's notification handlers.
/// This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
#if !NO_VARIANCE
public interface IObserver<in TValue, out TResult>
#else
public interface IObserver<TValue, TResult>
#endif
{
/// <summary>
/// Notifies the observer of a new element in the sequence.
/// </summary>
/// <param name="value">The new element in the sequence.</param>
/// <returns>Result returned upon observation of a new element.</returns>
TResult OnNext(TValue value);
/// <summary>
/// Notifies the observer that an exception has occurred.
/// </summary>
/// <param name="exception">The exception that occurred.</param>
/// <returns>Result returned upon observation of an error.</returns>
TResult OnError(Exception exception);
/// <summary>
/// Notifies the observer of the end of the sequence.
/// </summary>
/// <returns>Result returned upon observation of the sequence completion.</returns>
TResult OnCompleted();
}
}

View File

@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive.Linq
{
/// <summary>
/// Represents an observable sequence of elements that have a common key.
/// </summary>
/// <typeparam name="TKey">
/// The type of the key shared by all elements in the group.
/// This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
/// <typeparam name="TElement">
/// The type of the elements in the group.
/// This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
#if !NO_VARIANCE
public interface IGroupedObservable<out TKey, out TElement> : IObservable<TElement>
#else
public interface IGroupedObservable<TKey, TElement> : IObservable<TElement>
#endif
{
/// <summary>
/// Gets the common key.
/// </summary>
TKey Key { get; }
}
}

View File

@@ -0,0 +1,46 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
#if !NO_EXPRESSIONS
using System.Linq.Expressions;
namespace System.Reactive.Linq
{
/// <summary>
/// Provides functionality to evaluate queries against a specific data source wherein the type of the data is known.
/// </summary>
/// <typeparam name="T">
/// The type of the data in the data source.
/// This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Justification = "What a pleasure to write 'by design' here.")]
public interface IQbservable<
#if !NO_VARIANCE
out
#endif
T> : IQbservable, IObservable<T>
{
}
/// <summary>
/// Provides functionality to evaluate queries against a specific data source wherein the type of the data is not specified.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Justification = "What a pleasure to write 'by design' here.")]
public interface IQbservable
{
/// <summary>
/// Gets the type of the element(s) that are returned when the expression tree associated with this instance of IQbservable is executed.
/// </summary>
Type ElementType { get; }
/// <summary>
/// Gets the expression tree that is associated with the instance of IQbservable.
/// </summary>
Expression Expression { get; }
/// <summary>
/// Gets the query provider that is associated with this data source.
/// </summary>
IQbservableProvider Provider { get; }
}
}
#endif

View File

@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
#if !NO_EXPRESSIONS
using System.Linq.Expressions;
namespace System.Reactive.Linq
{
/// <summary>
/// Defines methods to create and execute queries that are described by an IQbservable object.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Justification = "What a pleasure to write 'by design' here.")]
public interface IQbservableProvider
{
/// <summary>
/// Constructs an IQbservable&gt;TResult&lt; object that can evaluate the query represented by a specified expression tree.
/// </summary>
/// <typeparam name="TResult">The type of the elements of the System.Reactive.Linq.IQbservable&lt;T&gt; that is returned.</typeparam>
/// <param name="expression">Expression tree representing the query.</param>
/// <returns>IQbservable object that can evaluate the given query expression.</returns>
IQbservable<TResult> CreateQuery<TResult>(Expression expression);
}
}
#endif

View File

@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive.Subjects
{
/// <summary>
/// Represents an observable wrapper that can be connected and disconnected from its underlying observable sequence.
/// </summary>
/// <typeparam name="T">
/// The type of the elements in the sequence.
/// This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
#if !NO_VARIANCE
public interface IConnectableObservable<out T> : IObservable<T>
#else
public interface IConnectableObservable<T> : IObservable<T>
#endif
{
/// <summary>
/// Connects the observable wrapper to its source. All subscribed observers will receive values from the underlying observable sequence as long as the connection is established.
/// </summary>
/// <returns>Disposable used to disconnect the observable wrapper from its source, causing subscribed observer to stop receiving values from the underlying observable sequence.</returns>
IDisposable Connect();
}
}

View File

@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive.Subjects
{
/// <summary>
/// Represents an object that is both an observable sequence as well as an observer.
/// </summary>
/// <typeparam name="TSource">
/// The type of the elements received by the subject.
/// This type parameter is contravariant. That is, you can use either the type you specified or any type that is less derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
/// <typeparam name="TResult">
/// The type of the elements produced by the subject.
/// This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
#if !NO_VARIANCE
public interface ISubject<in TSource, out TResult> : IObserver<TSource>, IObservable<TResult>
#else
public interface ISubject<TSource, TResult> : IObserver<TSource>, IObservable<TResult>
#endif
{
}
}

View File

@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive.Subjects
{
/// <summary>
/// Represents an object that is both an observable sequence as well as an observer.
/// </summary>
/// <typeparam name="T">The type of the elements processed by the subject.</typeparam>
public interface ISubject<T> : ISubject<T, T>
{
}
}