| 1 |
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. |
| 2 |
|
| 3 |
using System.Reactive.Concurrency; |
| 4 |
using System.Threading; |
| 5 |
|
| 6 |
namespace System.Reactive.Linq |
| 7 |
{ |
| 8 |
public static partial class Observable |
| 9 |
{ |
| 10 |
#region + FromEventPattern + |
| 11 |
|
| 12 |
#region Strongly typed |
| 13 |
|
| 14 |
#region Action<EventHandler> |
| 15 |
|
| 16 |
/// <summary> |
| 17 |
/// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler"/>, to an observable sequence. |
| 18 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 19 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 20 |
/// </summary> |
| 21 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 22 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 23 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 24 |
/// <exception cref="ArgumentNullException"><paramref name="addHandler"/> or <paramref name="removeHandler"/> is null.</exception> |
| 25 |
/// <remarks> |
| 26 |
/// <para> |
| 27 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 28 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 29 |
/// </para> |
| 30 |
/// <para> |
| 31 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations. |
| 32 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 33 |
/// </para> |
| 34 |
/// <para> |
| 35 |
/// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread |
| 36 |
/// making the Subscribe or Dispose call, respectively. |
| 37 |
/// </para> |
| 38 |
/// <para> |
| 39 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 40 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 41 |
/// more concise and easier to understand. |
| 42 |
/// </para> |
| 43 |
/// </remarks> |
| 44 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 45 |
#if !NO_EVENTARGS_CONSTRAINT |
| 46 |
public static IObservable<EventPattern<EventArgs>> FromEventPattern(Action<EventHandler> addHandler, Action<EventHandler> removeHandler) |
| 47 |
{ |
| 48 |
if (addHandler == null) |
| 49 |
throw new ArgumentNullException("addHandler"); |
| 50 |
if (removeHandler == null) |
| 51 |
throw new ArgumentNullException("removeHandler"); |
| 52 |
|
| 53 |
return s_impl.FromEventPattern(addHandler, removeHandler); |
| 54 |
} |
| 55 |
#else |
| 56 |
public static IObservable<EventPattern<object>> FromEventPattern(Action<EventHandler> addHandler, Action<EventHandler> removeHandler) |
| 57 |
{ |
| 58 |
if (addHandler == null) |
| 59 |
throw new ArgumentNullException("addHandler"); |
| 60 |
if (removeHandler == null) |
| 61 |
throw new ArgumentNullException("removeHandler"); |
| 62 |
|
| 63 |
return s_impl.FromEventPattern(addHandler, removeHandler); |
| 64 |
} |
| 65 |
#endif |
| 66 |
|
| 67 |
/// <summary> |
| 68 |
/// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler"/>, to an observable sequence. |
| 69 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 70 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 71 |
/// </summary> |
| 72 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 73 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 74 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 75 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 76 |
/// <exception cref="ArgumentNullException"><paramref name="addHandler"/> or <paramref name="removeHandler"/> or <paramref name="scheduler"/> is null.</exception> |
| 77 |
/// <remarks> |
| 78 |
/// <para> |
| 79 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 80 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 81 |
/// </para> |
| 82 |
/// <para> |
| 83 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 84 |
/// accessed from the same context, as required by some UI frameworks. |
| 85 |
/// </para> |
| 86 |
/// <para> |
| 87 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 88 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler |
| 89 |
/// parameter. For more information, see the remarks section on those overloads. |
| 90 |
/// </para> |
| 91 |
/// </remarks> |
| 92 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 93 |
#if !NO_EVENTARGS_CONSTRAINT |
| 94 |
public static IObservable<EventPattern<EventArgs>> FromEventPattern(Action<EventHandler> addHandler, Action<EventHandler> removeHandler, IScheduler scheduler) |
| 95 |
{ |
| 96 |
if (addHandler == null) |
| 97 |
throw new ArgumentNullException("addHandler"); |
| 98 |
if (removeHandler == null) |
| 99 |
throw new ArgumentNullException("removeHandler"); |
| 100 |
if (scheduler == null) |
| 101 |
throw new ArgumentNullException("scheduler"); |
| 102 |
|
| 103 |
return s_impl.FromEventPattern(addHandler, removeHandler, scheduler); |
| 104 |
} |
| 105 |
#else |
| 106 |
public static IObservable<EventPattern<object>> FromEventPattern(Action<EventHandler> addHandler, Action<EventHandler> removeHandler, IScheduler scheduler) |
| 107 |
{ |
| 108 |
if (addHandler == null) |
| 109 |
throw new ArgumentNullException("addHandler"); |
| 110 |
if (removeHandler == null) |
| 111 |
throw new ArgumentNullException("removeHandler"); |
| 112 |
if (scheduler == null) |
| 113 |
throw new ArgumentNullException("scheduler"); |
| 114 |
|
| 115 |
return s_impl.FromEventPattern(addHandler, removeHandler, scheduler); |
| 116 |
} |
| 117 |
#endif |
| 118 |
|
| 119 |
#endregion |
| 120 |
|
| 121 |
#region Action<TDelegate> |
| 122 |
|
| 123 |
/// <summary> |
| 124 |
/// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence. |
| 125 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 126 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 127 |
/// </summary> |
| 128 |
/// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam> |
| 129 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 130 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 131 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 132 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 133 |
/// <exception cref="ArgumentNullException"><paramref name="addHandler"/> or <paramref name="removeHandler"/> is null.</exception> |
| 134 |
/// <remarks> |
| 135 |
/// <para> |
| 136 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 137 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 138 |
/// </para> |
| 139 |
/// <para> |
| 140 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations. |
| 141 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 142 |
/// </para> |
| 143 |
/// <para> |
| 144 |
/// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread |
| 145 |
/// making the Subscribe or Dispose call, respectively. |
| 146 |
/// </para> |
| 147 |
/// <para> |
| 148 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 149 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 150 |
/// more concise and easier to understand. |
| 151 |
/// </para> |
| 152 |
/// </remarks> |
| 153 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 154 |
public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(Action<TDelegate> addHandler, Action<TDelegate> removeHandler) |
| 155 |
#if !NO_EVENTARGS_CONSTRAINT |
| 156 |
where TEventArgs : EventArgs |
| 157 |
#endif |
| 158 |
{ |
| 159 |
if (addHandler == null) |
| 160 |
throw new ArgumentNullException("addHandler"); |
| 161 |
if (removeHandler == null) |
| 162 |
throw new ArgumentNullException("removeHandler"); |
| 163 |
|
| 164 |
return s_impl.FromEventPattern<TDelegate, TEventArgs>(addHandler, removeHandler); |
| 165 |
} |
| 166 |
|
| 167 |
/// <summary> |
| 168 |
/// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence. |
| 169 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 170 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 171 |
/// </summary> |
| 172 |
/// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam> |
| 173 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 174 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 175 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 176 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 177 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 178 |
/// <exception cref="ArgumentNullException"><paramref name="addHandler"/> or <paramref name="removeHandler"/> or <paramref name="scheduler"/> is null.</exception> |
| 179 |
/// <remarks> |
| 180 |
/// <para> |
| 181 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 182 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 183 |
/// </para> |
| 184 |
/// <para> |
| 185 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 186 |
/// accessed from the same context, as required by some UI frameworks. |
| 187 |
/// </para> |
| 188 |
/// <para> |
| 189 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 190 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler |
| 191 |
/// parameter. For more information, see the remarks section on those overloads. |
| 192 |
/// </para> |
| 193 |
/// </remarks> |
| 194 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 195 |
public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(Action<TDelegate> addHandler, Action<TDelegate> removeHandler, IScheduler scheduler) |
| 196 |
#if !NO_EVENTARGS_CONSTRAINT |
| 197 |
where TEventArgs : EventArgs |
| 198 |
#endif |
| 199 |
{ |
| 200 |
if (addHandler == null) |
| 201 |
throw new ArgumentNullException("addHandler"); |
| 202 |
if (removeHandler == null) |
| 203 |
throw new ArgumentNullException("removeHandler"); |
| 204 |
if (scheduler == null) |
| 205 |
throw new ArgumentNullException("scheduler"); |
| 206 |
|
| 207 |
return s_impl.FromEventPattern<TDelegate, TEventArgs>(addHandler, removeHandler, scheduler); |
| 208 |
} |
| 209 |
|
| 210 |
/// <summary> |
| 211 |
/// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler<TEventArgs>"/>, to an observable sequence. |
| 212 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 213 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 214 |
/// </summary> |
| 215 |
/// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam> |
| 216 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 217 |
/// <param name="conversion">A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters.</param> |
| 218 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 219 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 220 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 221 |
/// <exception cref="ArgumentNullException"><paramref name="conversion"/> or <paramref name="addHandler"/> or <paramref name="removeHandler"/> is null.</exception> |
| 222 |
/// <remarks> |
| 223 |
/// <para> |
| 224 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 225 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 226 |
/// </para> |
| 227 |
/// <para> |
| 228 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations. |
| 229 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 230 |
/// </para> |
| 231 |
/// <para> |
| 232 |
/// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread |
| 233 |
/// making the Subscribe or Dispose call, respectively. |
| 234 |
/// </para> |
| 235 |
/// <para> |
| 236 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 237 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 238 |
/// more concise and easier to understand. |
| 239 |
/// </para> |
| 240 |
/// </remarks> |
| 241 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 242 |
public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(Func<EventHandler<TEventArgs>, TDelegate> conversion, Action<TDelegate> addHandler, Action<TDelegate> removeHandler) |
| 243 |
#if !NO_EVENTARGS_CONSTRAINT |
| 244 |
where TEventArgs : EventArgs |
| 245 |
#endif |
| 246 |
{ |
| 247 |
if (conversion == null) |
| 248 |
throw new ArgumentNullException("conversion"); |
| 249 |
if (addHandler == null) |
| 250 |
throw new ArgumentNullException("addHandler"); |
| 251 |
if (removeHandler == null) |
| 252 |
throw new ArgumentNullException("removeHandler"); |
| 253 |
|
| 254 |
return s_impl.FromEventPattern<TDelegate, TEventArgs>(conversion, addHandler, removeHandler); |
| 255 |
} |
| 256 |
|
| 257 |
/// <summary> |
| 258 |
/// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler<TEventArgs>"/>, to an observable sequence. |
| 259 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 260 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 261 |
/// </summary> |
| 262 |
/// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam> |
| 263 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 264 |
/// <param name="conversion">A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters.</param> |
| 265 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 266 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 267 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 268 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 269 |
/// <exception cref="ArgumentNullException"><paramref name="conversion"/> or <paramref name="addHandler"/> or <paramref name="removeHandler"/> or <paramref name="scheduler"/> is null.</exception> |
| 270 |
/// <remarks> |
| 271 |
/// <para> |
| 272 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 273 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 274 |
/// </para> |
| 275 |
/// <para> |
| 276 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 277 |
/// accessed from the same context, as required by some UI frameworks. |
| 278 |
/// </para> |
| 279 |
/// <para> |
| 280 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 281 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler |
| 282 |
/// parameter. For more information, see the remarks section on those overloads. |
| 283 |
/// </para> |
| 284 |
/// </remarks> |
| 285 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 286 |
public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(Func<EventHandler<TEventArgs>, TDelegate> conversion, Action<TDelegate> addHandler, Action<TDelegate> removeHandler, IScheduler scheduler) |
| 287 |
#if !NO_EVENTARGS_CONSTRAINT |
| 288 |
where TEventArgs : EventArgs |
| 289 |
#endif |
| 290 |
{ |
| 291 |
if (conversion == null) |
| 292 |
throw new ArgumentNullException("conversion"); |
| 293 |
if (addHandler == null) |
| 294 |
throw new ArgumentNullException("addHandler"); |
| 295 |
if (removeHandler == null) |
| 296 |
throw new ArgumentNullException("removeHandler"); |
| 297 |
if (scheduler == null) |
| 298 |
throw new ArgumentNullException("scheduler"); |
| 299 |
|
| 300 |
return s_impl.FromEventPattern<TDelegate, TEventArgs>(conversion, addHandler, removeHandler, scheduler); |
| 301 |
} |
| 302 |
|
| 303 |
/// <summary> |
| 304 |
/// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type with a strongly typed sender parameter, to an observable sequence. |
| 305 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 306 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 307 |
/// </summary> |
| 308 |
/// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam> |
| 309 |
/// <typeparam name="TSender">The type of the sender that raises the event.</typeparam> |
| 310 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 311 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 312 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 313 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 314 |
/// <exception cref="ArgumentNullException"><paramref name="addHandler"/> or <paramref name="removeHandler"/> is null.</exception> |
| 315 |
/// <remarks> |
| 316 |
/// <para> |
| 317 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 318 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 319 |
/// </para> |
| 320 |
/// <para> |
| 321 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations. |
| 322 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 323 |
/// </para> |
| 324 |
/// <para> |
| 325 |
/// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread |
| 326 |
/// making the Subscribe or Dispose call, respectively. |
| 327 |
/// </para> |
| 328 |
/// <para> |
| 329 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 330 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 331 |
/// more concise and easier to understand. |
| 332 |
/// </para> |
| 333 |
/// </remarks> |
| 334 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 335 |
public static IObservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(Action<TDelegate> addHandler, Action<TDelegate> removeHandler) |
| 336 |
#if !NO_EVENTARGS_CONSTRAINT |
| 337 |
where TEventArgs : EventArgs |
| 338 |
#endif |
| 339 |
{ |
| 340 |
if (addHandler == null) |
| 341 |
throw new ArgumentNullException("addHandler"); |
| 342 |
if (removeHandler == null) |
| 343 |
throw new ArgumentNullException("removeHandler"); |
| 344 |
|
| 345 |
return s_impl.FromEventPattern<TDelegate, TSender, TEventArgs>(addHandler, removeHandler); |
| 346 |
} |
| 347 |
|
| 348 |
/// <summary> |
| 349 |
/// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type with a strongly typed sender parameter, to an observable sequence. |
| 350 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 351 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 352 |
/// </summary> |
| 353 |
/// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam> |
| 354 |
/// <typeparam name="TSender">The type of the sender that raises the event.</typeparam> |
| 355 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 356 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 357 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 358 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 359 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 360 |
/// <exception cref="ArgumentNullException"><paramref name="addHandler"/> or <paramref name="removeHandler"/> or <paramref name="scheduler"/> is null.</exception> |
| 361 |
/// <remarks> |
| 362 |
/// <para> |
| 363 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 364 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 365 |
/// </para> |
| 366 |
/// <para> |
| 367 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 368 |
/// accessed from the same context, as required by some UI frameworks. |
| 369 |
/// </para> |
| 370 |
/// <para> |
| 371 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 372 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler |
| 373 |
/// parameter. For more information, see the remarks section on those overloads. |
| 374 |
/// </para> |
| 375 |
/// </remarks> |
| 376 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 377 |
public static IObservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(Action<TDelegate> addHandler, Action<TDelegate> removeHandler, IScheduler scheduler) |
| 378 |
#if !NO_EVENTARGS_CONSTRAINT |
| 379 |
where TEventArgs : EventArgs |
| 380 |
#endif |
| 381 |
{ |
| 382 |
if (addHandler == null) |
| 383 |
throw new ArgumentNullException("addHandler"); |
| 384 |
if (removeHandler == null) |
| 385 |
throw new ArgumentNullException("removeHandler"); |
| 386 |
if (scheduler == null) |
| 387 |
throw new ArgumentNullException("scheduler"); |
| 388 |
|
| 389 |
return s_impl.FromEventPattern<TDelegate, TSender, TEventArgs>(addHandler, removeHandler, scheduler); |
| 390 |
} |
| 391 |
|
| 392 |
#endregion |
| 393 |
|
| 394 |
#region Action<EventHandler<TEventArgs>> |
| 395 |
|
| 396 |
/// <summary> |
| 397 |
/// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler<TEventArgs>"/>, to an observable sequence. |
| 398 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 399 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 400 |
/// </summary> |
| 401 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 402 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 403 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 404 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 405 |
/// <remarks> |
| 406 |
/// <para> |
| 407 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 408 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 409 |
/// </para> |
| 410 |
/// <para> |
| 411 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations. |
| 412 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 413 |
/// </para> |
| 414 |
/// <para> |
| 415 |
/// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread |
| 416 |
/// making the Subscribe or Dispose call, respectively. |
| 417 |
/// </para> |
| 418 |
/// <para> |
| 419 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 420 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 421 |
/// more concise and easier to understand. |
| 422 |
/// </para> |
| 423 |
/// </remarks> |
| 424 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 425 |
public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(Action<EventHandler<TEventArgs>> addHandler, Action<EventHandler<TEventArgs>> removeHandler) |
| 426 |
#if !NO_EVENTARGS_CONSTRAINT |
| 427 |
where TEventArgs : EventArgs |
| 428 |
#endif |
| 429 |
{ |
| 430 |
if (addHandler == null) |
| 431 |
throw new ArgumentNullException("addHandler"); |
| 432 |
if (removeHandler == null) |
| 433 |
throw new ArgumentNullException("removeHandler"); |
| 434 |
|
| 435 |
return s_impl.FromEventPattern<TEventArgs>(addHandler, removeHandler); |
| 436 |
} |
| 437 |
|
| 438 |
/// <summary> |
| 439 |
/// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler<TEventArgs>"/>, to an observable sequence. |
| 440 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 441 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 442 |
/// </summary> |
| 443 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 444 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 445 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 446 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 447 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 448 |
/// <remarks> |
| 449 |
/// <para> |
| 450 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 451 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 452 |
/// </para> |
| 453 |
/// <para> |
| 454 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 455 |
/// accessed from the same context, as required by some UI frameworks. |
| 456 |
/// </para> |
| 457 |
/// <para> |
| 458 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 459 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler |
| 460 |
/// parameter. For more information, see the remarks section on those overloads. |
| 461 |
/// </para> |
| 462 |
/// </remarks> |
| 463 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 464 |
public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(Action<EventHandler<TEventArgs>> addHandler, Action<EventHandler<TEventArgs>> removeHandler, IScheduler scheduler) |
| 465 |
#if !NO_EVENTARGS_CONSTRAINT |
| 466 |
where TEventArgs : EventArgs |
| 467 |
#endif |
| 468 |
{ |
| 469 |
if (addHandler == null) |
| 470 |
throw new ArgumentNullException("addHandler"); |
| 471 |
if (removeHandler == null) |
| 472 |
throw new ArgumentNullException("removeHandler"); |
| 473 |
if (scheduler == null) |
| 474 |
throw new ArgumentNullException("scheduler"); |
| 475 |
|
| 476 |
return s_impl.FromEventPattern<TEventArgs>(addHandler, removeHandler, scheduler); |
| 477 |
} |
| 478 |
|
| 479 |
#endregion |
| 480 |
|
| 481 |
#endregion |
| 482 |
|
| 483 |
#region Reflection |
| 484 |
|
| 485 |
#region Instance events |
| 486 |
|
| 487 |
/// <summary> |
| 488 |
/// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs"/> parameter, to an observable sequence. |
| 489 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 490 |
/// Reflection is used to discover the event based on the target object type and the specified event name. |
| 491 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 492 |
/// </summary> |
| 493 |
/// <param name="target">Object instance that exposes the event to convert.</param> |
| 494 |
/// <param name="eventName">Name of the event to convert.</param> |
| 495 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 496 |
/// <exception cref="ArgumentNullException"><paramref name="target"/> or <paramref name="eventName"/> is null.</exception> |
| 497 |
/// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception> |
| 498 |
/// <remarks> |
| 499 |
/// <para> |
| 500 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 501 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 502 |
/// </para> |
| 503 |
/// <para> |
| 504 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations. |
| 505 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 506 |
/// </para> |
| 507 |
/// <para> |
| 508 |
/// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread |
| 509 |
/// making the Subscribe or Dispose call, respectively. |
| 510 |
/// </para> |
| 511 |
/// <para> |
| 512 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 513 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 514 |
/// more concise and easier to understand. |
| 515 |
/// </para> |
| 516 |
/// </remarks> |
| 517 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 518 |
#if !NO_EVENTARGS_CONSTRAINT |
| 519 |
public static IObservable<EventPattern<EventArgs>> FromEventPattern(object target, string eventName) |
| 520 |
{ |
| 521 |
if (target == null) |
| 522 |
throw new ArgumentNullException("target"); |
| 523 |
if (eventName == null) |
| 524 |
throw new ArgumentNullException("eventName"); |
| 525 |
|
| 526 |
return s_impl.FromEventPattern(target, eventName); |
| 527 |
} |
| 528 |
#else |
| 529 |
public static IObservable<EventPattern<object>> FromEventPattern(object target, string eventName) |
| 530 |
{ |
| 531 |
if (target == null) |
| 532 |
throw new ArgumentNullException("target"); |
| 533 |
if (eventName == null) |
| 534 |
throw new ArgumentNullException("eventName"); |
| 535 |
|
| 536 |
return s_impl.FromEventPattern(target, eventName); |
| 537 |
} |
| 538 |
#endif |
| 539 |
|
| 540 |
/// <summary> |
| 541 |
/// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs"/> parameter, to an observable sequence. |
| 542 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 543 |
/// Reflection is used to discover the event based on the target object type and the specified event name. |
| 544 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 545 |
/// </summary> |
| 546 |
/// <param name="target">Object instance that exposes the event to convert.</param> |
| 547 |
/// <param name="eventName">Name of the event to convert.</param> |
| 548 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 549 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 550 |
/// <exception cref="ArgumentNullException"><paramref name="target"/> or <paramref name="eventName"/> or <paramref name="scheduler"/> is null.</exception> |
| 551 |
/// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception> |
| 552 |
/// <remarks> |
| 553 |
/// <para> |
| 554 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 555 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 556 |
/// </para> |
| 557 |
/// <para> |
| 558 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 559 |
/// accessed from the same context, as required by some UI frameworks. |
| 560 |
/// </para> |
| 561 |
/// <para> |
| 562 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 563 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler |
| 564 |
/// parameter. For more information, see the remarks section on those overloads. |
| 565 |
/// </para> |
| 566 |
/// </remarks> |
| 567 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 568 |
#if !NO_EVENTARGS_CONSTRAINT |
| 569 |
public static IObservable<EventPattern<EventArgs>> FromEventPattern(object target, string eventName, IScheduler scheduler) |
| 570 |
{ |
| 571 |
if (target == null) |
| 572 |
throw new ArgumentNullException("target"); |
| 573 |
if (eventName == null) |
| 574 |
throw new ArgumentNullException("eventName"); |
| 575 |
if (scheduler == null) |
| 576 |
throw new ArgumentNullException("scheduler"); |
| 577 |
|
| 578 |
return s_impl.FromEventPattern(target, eventName, scheduler); |
| 579 |
} |
| 580 |
#else |
| 581 |
public static IObservable<EventPattern<object>> FromEventPattern(object target, string eventName, IScheduler scheduler) |
| 582 |
{ |
| 583 |
if (target == null) |
| 584 |
throw new ArgumentNullException("target"); |
| 585 |
if (eventName == null) |
| 586 |
throw new ArgumentNullException("eventName"); |
| 587 |
if (scheduler == null) |
| 588 |
throw new ArgumentNullException("scheduler"); |
| 589 |
|
| 590 |
return s_impl.FromEventPattern(target, eventName, scheduler); |
| 591 |
} |
| 592 |
#endif |
| 593 |
|
| 594 |
/// <summary> |
| 595 |
/// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence. |
| 596 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 597 |
/// Reflection is used to discover the event based on the target object type and the specified event name. |
| 598 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 599 |
/// </summary> |
| 600 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 601 |
/// <param name="target">Object instance that exposes the event to convert.</param> |
| 602 |
/// <param name="eventName">Name of the event to convert.</param> |
| 603 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 604 |
/// <exception cref="ArgumentNullException"><paramref name="target"/> or <paramref name="eventName"/> is null.</exception> |
| 605 |
/// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.</exception> |
| 606 |
/// <remarks> |
| 607 |
/// <para> |
| 608 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 609 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 610 |
/// </para> |
| 611 |
/// <para> |
| 612 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations. |
| 613 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 614 |
/// </para> |
| 615 |
/// <para> |
| 616 |
/// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread |
| 617 |
/// making the Subscribe or Dispose call, respectively. |
| 618 |
/// </para> |
| 619 |
/// <para> |
| 620 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 621 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 622 |
/// more concise and easier to understand. |
| 623 |
/// </para> |
| 624 |
/// </remarks> |
| 625 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 626 |
public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(object target, string eventName) |
| 627 |
#if !NO_EVENTARGS_CONSTRAINT |
| 628 |
where TEventArgs : EventArgs |
| 629 |
#endif |
| 630 |
{ |
| 631 |
if (target == null) |
| 632 |
throw new ArgumentNullException("target"); |
| 633 |
if (eventName == null) |
| 634 |
throw new ArgumentNullException("eventName"); |
| 635 |
|
| 636 |
return s_impl.FromEventPattern<TEventArgs>(target, eventName); |
| 637 |
} |
| 638 |
|
| 639 |
/// <summary> |
| 640 |
/// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence. |
| 641 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 642 |
/// Reflection is used to discover the event based on the target object type and the specified event name. |
| 643 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 644 |
/// </summary> |
| 645 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 646 |
/// <param name="target">Object instance that exposes the event to convert.</param> |
| 647 |
/// <param name="eventName">Name of the event to convert.</param> |
| 648 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 649 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 650 |
/// <exception cref="ArgumentNullException"><paramref name="target"/> or <paramref name="eventName"/> or <paramref name="scheduler"/> is null.</exception> |
| 651 |
/// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.</exception> |
| 652 |
/// <remarks> |
| 653 |
/// <para> |
| 654 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 655 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 656 |
/// </para> |
| 657 |
/// <para> |
| 658 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 659 |
/// accessed from the same context, as required by some UI frameworks. |
| 660 |
/// </para> |
| 661 |
/// <para> |
| 662 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 663 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler |
| 664 |
/// parameter. For more information, see the remarks section on those overloads. |
| 665 |
/// </para> |
| 666 |
/// </remarks> |
| 667 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 668 |
public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(object target, string eventName, IScheduler scheduler) |
| 669 |
#if !NO_EVENTARGS_CONSTRAINT |
| 670 |
where TEventArgs : EventArgs |
| 671 |
#endif |
| 672 |
{ |
| 673 |
if (target == null) |
| 674 |
throw new ArgumentNullException("target"); |
| 675 |
if (eventName == null) |
| 676 |
throw new ArgumentNullException("eventName"); |
| 677 |
if (scheduler == null) |
| 678 |
throw new ArgumentNullException("scheduler"); |
| 679 |
|
| 680 |
return s_impl.FromEventPattern<TEventArgs>(target, eventName, scheduler); |
| 681 |
} |
| 682 |
|
| 683 |
/// <summary> |
| 684 |
/// Converts an instance .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence. |
| 685 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 686 |
/// Reflection is used to discover the event based on the target object type and the specified event name. |
| 687 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 688 |
/// </summary> |
| 689 |
/// <typeparam name="TSender">The type of the sender that raises the event.</typeparam> |
| 690 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 691 |
/// <param name="target">Object instance that exposes the event to convert.</param> |
| 692 |
/// <param name="eventName">Name of the event to convert.</param> |
| 693 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 694 |
/// <exception cref="ArgumentNullException"><paramref name="target"/> or <paramref name="eventName"/> is null.</exception> |
| 695 |
/// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.</exception> |
| 696 |
/// <remarks> |
| 697 |
/// <para> |
| 698 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 699 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 700 |
/// </para> |
| 701 |
/// <para> |
| 702 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations. |
| 703 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 704 |
/// </para> |
| 705 |
/// <para> |
| 706 |
/// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread |
| 707 |
/// making the Subscribe or Dispose call, respectively. |
| 708 |
/// </para> |
| 709 |
/// <para> |
| 710 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 711 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 712 |
/// more concise and easier to understand. |
| 713 |
/// </para> |
| 714 |
/// </remarks> |
| 715 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 716 |
public static IObservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(object target, string eventName) |
| 717 |
#if !NO_EVENTARGS_CONSTRAINT |
| 718 |
where TEventArgs : EventArgs |
| 719 |
#endif |
| 720 |
{ |
| 721 |
if (target == null) |
| 722 |
throw new ArgumentNullException("target"); |
| 723 |
if (eventName == null) |
| 724 |
throw new ArgumentNullException("eventName"); |
| 725 |
|
| 726 |
return s_impl.FromEventPattern<TSender, TEventArgs>(target, eventName); |
| 727 |
} |
| 728 |
|
| 729 |
/// <summary> |
| 730 |
/// Converts an instance .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence. |
| 731 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 732 |
/// Reflection is used to discover the event based on the target object type and the specified event name. |
| 733 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 734 |
/// </summary> |
| 735 |
/// <typeparam name="TSender">The type of the sender that raises the event.</typeparam> |
| 736 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 737 |
/// <param name="target">Object instance that exposes the event to convert.</param> |
| 738 |
/// <param name="eventName">Name of the event to convert.</param> |
| 739 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 740 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 741 |
/// <exception cref="ArgumentNullException"><paramref name="target"/> or <paramref name="eventName"/> or <paramref name="scheduler"/> is null.</exception> |
| 742 |
/// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.</exception> |
| 743 |
/// <remarks> |
| 744 |
/// <para> |
| 745 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 746 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 747 |
/// </para> |
| 748 |
/// <para> |
| 749 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 750 |
/// accessed from the same context, as required by some UI frameworks. |
| 751 |
/// </para> |
| 752 |
/// <para> |
| 753 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 754 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler |
| 755 |
/// parameter. For more information, see the remarks section on those overloads. |
| 756 |
/// </para> |
| 757 |
/// </remarks> |
| 758 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 759 |
public static IObservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(object target, string eventName, IScheduler scheduler) |
| 760 |
#if !NO_EVENTARGS_CONSTRAINT |
| 761 |
where TEventArgs : EventArgs |
| 762 |
#endif |
| 763 |
{ |
| 764 |
if (target == null) |
| 765 |
throw new ArgumentNullException("target"); |
| 766 |
if (eventName == null) |
| 767 |
throw new ArgumentNullException("eventName"); |
| 768 |
if (scheduler == null) |
| 769 |
throw new ArgumentNullException("scheduler"); |
| 770 |
|
| 771 |
return s_impl.FromEventPattern<TSender, TEventArgs>(target, eventName, scheduler); |
| 772 |
} |
| 773 |
|
| 774 |
#endregion |
| 775 |
|
| 776 |
#region Static events |
| 777 |
|
| 778 |
/// <summary> |
| 779 |
/// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs"/> parameter, to an observable sequence. |
| 780 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 781 |
/// Reflection is used to discover the event based on the specified type and the specified event name. |
| 782 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 783 |
/// </summary> |
| 784 |
/// <param name="type">Type that exposes the static event to convert.</param> |
| 785 |
/// <param name="eventName">Name of the event to convert.</param> |
| 786 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 787 |
/// <exception cref="ArgumentNullException"><paramref name="type"/> or <paramref name="eventName"/> is null.</exception> |
| 788 |
/// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception> |
| 789 |
/// <remarks> |
| 790 |
/// <para> |
| 791 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 792 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 793 |
/// </para> |
| 794 |
/// <para> |
| 795 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations. |
| 796 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 797 |
/// </para> |
| 798 |
/// <para> |
| 799 |
/// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread |
| 800 |
/// making the Subscribe or Dispose call, respectively. |
| 801 |
/// </para> |
| 802 |
/// <para> |
| 803 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 804 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 805 |
/// more concise and easier to understand. |
| 806 |
/// </para> |
| 807 |
/// </remarks> |
| 808 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 809 |
#if !NO_EVENTARGS_CONSTRAINT |
| 810 |
public static IObservable<EventPattern<EventArgs>> FromEventPattern(Type type, string eventName) |
| 811 |
{ |
| 812 |
if (type == null) |
| 813 |
throw new ArgumentNullException("type"); |
| 814 |
if (eventName == null) |
| 815 |
throw new ArgumentNullException("eventName"); |
| 816 |
|
| 817 |
return s_impl.FromEventPattern(type, eventName); |
| 818 |
} |
| 819 |
#else |
| 820 |
public static IObservable<EventPattern<object>> FromEventPattern(Type type, string eventName) |
| 821 |
{ |
| 822 |
if (type == null) |
| 823 |
throw new ArgumentNullException("type"); |
| 824 |
if (eventName == null) |
| 825 |
throw new ArgumentNullException("eventName"); |
| 826 |
|
| 827 |
return s_impl.FromEventPattern(type, eventName); |
| 828 |
} |
| 829 |
#endif |
| 830 |
|
| 831 |
/// <summary> |
| 832 |
/// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs"/> parameter, to an observable sequence. |
| 833 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 834 |
/// Reflection is used to discover the event based on the specified type and the specified event name. |
| 835 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 836 |
/// </summary> |
| 837 |
/// <param name="type">Type that exposes the static event to convert.</param> |
| 838 |
/// <param name="eventName">Name of the event to convert.</param> |
| 839 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 840 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 841 |
/// <exception cref="ArgumentNullException"><paramref name="type"/> or <paramref name="eventName"/> or <paramref name="scheduler"/> is null.</exception> |
| 842 |
/// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception> |
| 843 |
/// <remarks> |
| 844 |
/// <para> |
| 845 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 846 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 847 |
/// </para> |
| 848 |
/// <para> |
| 849 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 850 |
/// accessed from the same context, as required by some UI frameworks. |
| 851 |
/// </para> |
| 852 |
/// <para> |
| 853 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 854 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler |
| 855 |
/// parameter. For more information, see the remarks section on those overloads. |
| 856 |
/// </para> |
| 857 |
/// </remarks> |
| 858 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 859 |
#if !NO_EVENTARGS_CONSTRAINT |
| 860 |
public static IObservable<EventPattern<EventArgs>> FromEventPattern(Type type, string eventName, IScheduler scheduler) |
| 861 |
{ |
| 862 |
if (type == null) |
| 863 |
throw new ArgumentNullException("type"); |
| 864 |
if (eventName == null) |
| 865 |
throw new ArgumentNullException("eventName"); |
| 866 |
if (scheduler == null) |
| 867 |
throw new ArgumentNullException("scheduler"); |
| 868 |
|
| 869 |
return s_impl.FromEventPattern(type, eventName, scheduler); |
| 870 |
} |
| 871 |
#else |
| 872 |
public static IObservable<EventPattern<object>> FromEventPattern(Type type, string eventName, IScheduler scheduler) |
| 873 |
{ |
| 874 |
if (type == null) |
| 875 |
throw new ArgumentNullException("type"); |
| 876 |
if (eventName == null) |
| 877 |
throw new ArgumentNullException("eventName"); |
| 878 |
if (scheduler == null) |
| 879 |
throw new ArgumentNullException("scheduler"); |
| 880 |
|
| 881 |
return s_impl.FromEventPattern(type, eventName, scheduler); |
| 882 |
} |
| 883 |
#endif |
| 884 |
|
| 885 |
/// <summary> |
| 886 |
/// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence. |
| 887 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 888 |
/// Reflection is used to discover the event based on the specified type and the specified event name. |
| 889 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 890 |
/// </summary> |
| 891 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 892 |
/// <param name="type">Type that exposes the static event to convert.</param> |
| 893 |
/// <param name="eventName">Name of the event to convert.</param> |
| 894 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 895 |
/// <exception cref="ArgumentNullException"><paramref name="type"/> or <paramref name="eventName"/> is null.</exception> |
| 896 |
/// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.</exception> |
| 897 |
/// <remarks> |
| 898 |
/// <para> |
| 899 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 900 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 901 |
/// </para> |
| 902 |
/// <para> |
| 903 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations. |
| 904 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 905 |
/// </para> |
| 906 |
/// <para> |
| 907 |
/// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread |
| 908 |
/// making the Subscribe or Dispose call, respectively. |
| 909 |
/// </para> |
| 910 |
/// <para> |
| 911 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 912 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 913 |
/// more concise and easier to understand. |
| 914 |
/// </para> |
| 915 |
/// </remarks> |
| 916 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 917 |
public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(Type type, string eventName) |
| 918 |
#if !NO_EVENTARGS_CONSTRAINT |
| 919 |
where TEventArgs : EventArgs |
| 920 |
#endif |
| 921 |
{ |
| 922 |
if (type == null) |
| 923 |
throw new ArgumentNullException("type"); |
| 924 |
if (eventName == null) |
| 925 |
throw new ArgumentNullException("eventName"); |
| 926 |
|
| 927 |
return s_impl.FromEventPattern<TEventArgs>(type, eventName); |
| 928 |
} |
| 929 |
|
| 930 |
/// <summary> |
| 931 |
/// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence. |
| 932 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 933 |
/// Reflection is used to discover the event based on the specified type and the specified event name. |
| 934 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 935 |
/// </summary> |
| 936 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 937 |
/// <param name="type">Type that exposes the static event to convert.</param> |
| 938 |
/// <param name="eventName">Name of the event to convert.</param> |
| 939 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 940 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 941 |
/// <exception cref="ArgumentNullException"><paramref name="type"/> or <paramref name="eventName"/> or <paramref name="scheduler"/> is null.</exception> |
| 942 |
/// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.</exception> |
| 943 |
/// <remarks> |
| 944 |
/// <para> |
| 945 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 946 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 947 |
/// </para> |
| 948 |
/// <para> |
| 949 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 950 |
/// accessed from the same context, as required by some UI frameworks. |
| 951 |
/// </para> |
| 952 |
/// <para> |
| 953 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 954 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler |
| 955 |
/// parameter. For more information, see the remarks section on those overloads. |
| 956 |
/// </para> |
| 957 |
/// </remarks> |
| 958 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 959 |
public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(Type type, string eventName, IScheduler scheduler) |
| 960 |
#if !NO_EVENTARGS_CONSTRAINT |
| 961 |
where TEventArgs : EventArgs |
| 962 |
#endif |
| 963 |
{ |
| 964 |
if (type == null) |
| 965 |
throw new ArgumentNullException("type"); |
| 966 |
if (eventName == null) |
| 967 |
throw new ArgumentNullException("eventName"); |
| 968 |
if (scheduler == null) |
| 969 |
throw new ArgumentNullException("scheduler"); |
| 970 |
|
| 971 |
return s_impl.FromEventPattern<TEventArgs>(type, eventName, scheduler); |
| 972 |
} |
| 973 |
|
| 974 |
/// <summary> |
| 975 |
/// Converts a static .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence. |
| 976 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 977 |
/// Reflection is used to discover the event based on the specified type and the specified event name. |
| 978 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 979 |
/// </summary> |
| 980 |
/// <typeparam name="TSender">The type of the sender that raises the event.</typeparam> |
| 981 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 982 |
/// <param name="type">Type that exposes the static event to convert.</param> |
| 983 |
/// <param name="eventName">Name of the event to convert.</param> |
| 984 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 985 |
/// <exception cref="ArgumentNullException"><paramref name="type"/> or <paramref name="eventName"/> is null.</exception> |
| 986 |
/// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.</exception> |
| 987 |
/// <remarks> |
| 988 |
/// <para> |
| 989 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 990 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 991 |
/// </para> |
| 992 |
/// <para> |
| 993 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations. |
| 994 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 995 |
/// </para> |
| 996 |
/// <para> |
| 997 |
/// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread |
| 998 |
/// making the Subscribe or Dispose call, respectively. |
| 999 |
/// </para> |
| 1000 |
/// <para> |
| 1001 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 1002 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 1003 |
/// more concise and easier to understand. |
| 1004 |
/// </para> |
| 1005 |
/// </remarks> |
| 1006 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 1007 |
public static IObservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(Type type, string eventName) |
| 1008 |
#if !NO_EVENTARGS_CONSTRAINT |
| 1009 |
where TEventArgs : EventArgs |
| 1010 |
#endif |
| 1011 |
{ |
| 1012 |
if (type == null) |
| 1013 |
throw new ArgumentNullException("type"); |
| 1014 |
if (eventName == null) |
| 1015 |
throw new ArgumentNullException("eventName"); |
| 1016 |
|
| 1017 |
return s_impl.FromEventPattern<TSender, TEventArgs>(type, eventName); |
| 1018 |
} |
| 1019 |
|
| 1020 |
/// <summary> |
| 1021 |
/// Converts a static .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence. |
| 1022 |
/// Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 1023 |
/// Reflection is used to discover the event based on the specified type and the specified event name. |
| 1024 |
/// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead. |
| 1025 |
/// </summary> |
| 1026 |
/// <typeparam name="TSender">The type of the sender that raises the event.</typeparam> |
| 1027 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 1028 |
/// <param name="type">Type that exposes the static event to convert.</param> |
| 1029 |
/// <param name="eventName">Name of the event to convert.</param> |
| 1030 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 1031 |
/// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns> |
| 1032 |
/// <exception cref="ArgumentNullException"><paramref name="type"/> or <paramref name="eventName"/> or <paramref name="scheduler"/> is null.</exception> |
| 1033 |
/// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.</exception> |
| 1034 |
/// <remarks> |
| 1035 |
/// <para> |
| 1036 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 1037 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 1038 |
/// </para> |
| 1039 |
/// <para> |
| 1040 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 1041 |
/// accessed from the same context, as required by some UI frameworks. |
| 1042 |
/// </para> |
| 1043 |
/// <para> |
| 1044 |
/// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 1045 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler |
| 1046 |
/// parameter. For more information, see the remarks section on those overloads. |
| 1047 |
/// </para> |
| 1048 |
/// </remarks> |
| 1049 |
/// <seealso cref="Observable.ToEventPattern"/> |
| 1050 |
public static IObservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(Type type, string eventName, IScheduler scheduler) |
| 1051 |
#if !NO_EVENTARGS_CONSTRAINT |
| 1052 |
where TEventArgs : EventArgs |
| 1053 |
#endif |
| 1054 |
{ |
| 1055 |
if (type == null) |
| 1056 |
throw new ArgumentNullException("type"); |
| 1057 |
if (eventName == null) |
| 1058 |
throw new ArgumentNullException("eventName"); |
| 1059 |
if (scheduler == null) |
| 1060 |
throw new ArgumentNullException("scheduler"); |
| 1061 |
|
| 1062 |
return s_impl.FromEventPattern<TSender, TEventArgs>(type, eventName, scheduler); |
| 1063 |
} |
| 1064 |
|
| 1065 |
#endregion |
| 1066 |
|
| 1067 |
#endregion |
| 1068 |
|
| 1069 |
#endregion |
| 1070 |
|
| 1071 |
#region + FromEvent + |
| 1072 |
|
| 1073 |
#region Action<TDelegate> |
| 1074 |
|
| 1075 |
/// <summary> |
| 1076 |
/// Converts a .NET event to an observable sequence, using a conversion function to obtain the event delegate. Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 1077 |
/// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead. |
| 1078 |
/// </summary> |
| 1079 |
/// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam> |
| 1080 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 1081 |
/// <param name="conversion">A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters.</param> |
| 1082 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 1083 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 1084 |
/// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns> |
| 1085 |
/// <exception cref="ArgumentNullException"><paramref name="conversion"/> or <paramref name="addHandler"/> or <paramref name="removeHandler"/> is null.</exception> |
| 1086 |
/// <remarks> |
| 1087 |
/// <para> |
| 1088 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 1089 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 1090 |
/// </para> |
| 1091 |
/// <para> |
| 1092 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEvent, and is used to post add and remove handler invocations. |
| 1093 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 1094 |
/// </para> |
| 1095 |
/// <para> |
| 1096 |
/// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread |
| 1097 |
/// making the Subscribe or Dispose call, respectively. |
| 1098 |
/// </para> |
| 1099 |
/// <para> |
| 1100 |
/// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 1101 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 1102 |
/// more concise and easier to understand. |
| 1103 |
/// </para> |
| 1104 |
/// </remarks> |
| 1105 |
/// <seealso cref="Observable.ToEvent"/> |
| 1106 |
public static IObservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(Func<Action<TEventArgs>, TDelegate> conversion, Action<TDelegate> addHandler, Action<TDelegate> removeHandler) |
| 1107 |
{ |
| 1108 |
if (conversion == null) |
| 1109 |
throw new ArgumentNullException("conversion"); |
| 1110 |
if (addHandler == null) |
| 1111 |
throw new ArgumentNullException("addHandler"); |
| 1112 |
if (removeHandler == null) |
| 1113 |
throw new ArgumentNullException("removeHandler"); |
| 1114 |
|
| 1115 |
return s_impl.FromEvent<TDelegate, TEventArgs>(conversion, addHandler, removeHandler); |
| 1116 |
} |
| 1117 |
|
| 1118 |
/// <summary> |
| 1119 |
/// Converts a .NET event to an observable sequence, using a conversion function to obtain the event delegate. Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 1120 |
/// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead. |
| 1121 |
/// </summary> |
| 1122 |
/// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam> |
| 1123 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 1124 |
/// <param name="conversion">A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters.</param> |
| 1125 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 1126 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 1127 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 1128 |
/// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns> |
| 1129 |
/// <exception cref="ArgumentNullException"><paramref name="conversion"/> or <paramref name="addHandler"/> or <paramref name="removeHandler"/> or <paramref name="scheduler"/> is null.</exception> |
| 1130 |
/// <remarks> |
| 1131 |
/// <para> |
| 1132 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 1133 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 1134 |
/// </para> |
| 1135 |
/// <para> |
| 1136 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 1137 |
/// accessed from the same context, as required by some UI frameworks. |
| 1138 |
/// </para> |
| 1139 |
/// <para> |
| 1140 |
/// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 1141 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler |
| 1142 |
/// parameter. For more information, see the remarks section on those overloads. |
| 1143 |
/// </para> |
| 1144 |
/// </remarks> |
| 1145 |
/// <seealso cref="Observable.ToEvent"/> |
| 1146 |
public static IObservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(Func<Action<TEventArgs>, TDelegate> conversion, Action<TDelegate> addHandler, Action<TDelegate> removeHandler, IScheduler scheduler) |
| 1147 |
{ |
| 1148 |
if (conversion == null) |
| 1149 |
throw new ArgumentNullException("conversion"); |
| 1150 |
if (addHandler == null) |
| 1151 |
throw new ArgumentNullException("addHandler"); |
| 1152 |
if (removeHandler == null) |
| 1153 |
throw new ArgumentNullException("removeHandler"); |
| 1154 |
if (scheduler == null) |
| 1155 |
throw new ArgumentNullException("scheduler"); |
| 1156 |
|
| 1157 |
return s_impl.FromEvent<TDelegate, TEventArgs>(conversion, addHandler, removeHandler, scheduler); |
| 1158 |
} |
| 1159 |
|
| 1160 |
/// <summary> |
| 1161 |
/// Converts a .NET event to an observable sequence, using a supplied event delegate type. Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 1162 |
/// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead. |
| 1163 |
/// </summary> |
| 1164 |
/// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam> |
| 1165 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 1166 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 1167 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 1168 |
/// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns> |
| 1169 |
/// <exception cref="ArgumentNullException"><paramref name="addHandler"/> or <paramref name="removeHandler"/> is null.</exception> |
| 1170 |
/// <remarks> |
| 1171 |
/// <para> |
| 1172 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 1173 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 1174 |
/// </para> |
| 1175 |
/// <para> |
| 1176 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEvent, and is used to post add and remove handler invocations. |
| 1177 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 1178 |
/// </para> |
| 1179 |
/// <para> |
| 1180 |
/// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread |
| 1181 |
/// making the Subscribe or Dispose call, respectively. |
| 1182 |
/// </para> |
| 1183 |
/// <para> |
| 1184 |
/// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 1185 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 1186 |
/// more concise and easier to understand. |
| 1187 |
/// </para> |
| 1188 |
/// </remarks> |
| 1189 |
/// <seealso cref="Observable.ToEvent"/> |
| 1190 |
public static IObservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(Action<TDelegate> addHandler, Action<TDelegate> removeHandler) |
| 1191 |
{ |
| 1192 |
if (addHandler == null) |
| 1193 |
throw new ArgumentNullException("addHandler"); |
| 1194 |
if (removeHandler == null) |
| 1195 |
throw new ArgumentNullException("removeHandler"); |
| 1196 |
|
| 1197 |
return s_impl.FromEvent<TDelegate, TEventArgs>(addHandler, removeHandler); |
| 1198 |
} |
| 1199 |
|
| 1200 |
/// <summary> |
| 1201 |
/// Converts a .NET event to an observable sequence, using a supplied event delegate type. Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 1202 |
/// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead. |
| 1203 |
/// </summary> |
| 1204 |
/// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam> |
| 1205 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 1206 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 1207 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 1208 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 1209 |
/// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns> |
| 1210 |
/// <exception cref="ArgumentNullException"><paramref name="addHandler"/> or <paramref name="removeHandler"/> or <paramref name="scheduler"/> is null.</exception> |
| 1211 |
/// <remarks> |
| 1212 |
/// <para> |
| 1213 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 1214 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 1215 |
/// </para> |
| 1216 |
/// <para> |
| 1217 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 1218 |
/// accessed from the same context, as required by some UI frameworks. |
| 1219 |
/// </para> |
| 1220 |
/// <para> |
| 1221 |
/// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 1222 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler |
| 1223 |
/// parameter. For more information, see the remarks section on those overloads. |
| 1224 |
/// </para> |
| 1225 |
/// </remarks> |
| 1226 |
/// <seealso cref="Observable.ToEvent"/> |
| 1227 |
public static IObservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(Action<TDelegate> addHandler, Action<TDelegate> removeHandler, IScheduler scheduler) |
| 1228 |
{ |
| 1229 |
if (addHandler == null) |
| 1230 |
throw new ArgumentNullException("addHandler"); |
| 1231 |
if (removeHandler == null) |
| 1232 |
throw new ArgumentNullException("removeHandler"); |
| 1233 |
if (scheduler == null) |
| 1234 |
throw new ArgumentNullException("scheduler"); |
| 1235 |
|
| 1236 |
return s_impl.FromEvent<TDelegate, TEventArgs>(addHandler, removeHandler, scheduler); |
| 1237 |
} |
| 1238 |
|
| 1239 |
#endregion |
| 1240 |
|
| 1241 |
#region Action<Action<TEventArgs>> |
| 1242 |
|
| 1243 |
/// <summary> |
| 1244 |
/// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 1245 |
/// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead. |
| 1246 |
/// </summary> |
| 1247 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 1248 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 1249 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 1250 |
/// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns> |
| 1251 |
/// <exception cref="ArgumentNullException"><paramref name="addHandler"/> or <paramref name="removeHandler"/> is null.</exception> |
| 1252 |
/// <remarks> |
| 1253 |
/// <para> |
| 1254 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 1255 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 1256 |
/// </para> |
| 1257 |
/// <para> |
| 1258 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEvent, and is used to post add and remove handler invocations. |
| 1259 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 1260 |
/// </para> |
| 1261 |
/// <para> |
| 1262 |
/// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread |
| 1263 |
/// making the Subscribe or Dispose call, respectively. |
| 1264 |
/// </para> |
| 1265 |
/// <para> |
| 1266 |
/// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 1267 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 1268 |
/// more concise and easier to understand. |
| 1269 |
/// </para> |
| 1270 |
/// </remarks> |
| 1271 |
/// <seealso cref="Observable.ToEvent"/> |
| 1272 |
public static IObservable<TEventArgs> FromEvent<TEventArgs>(Action<Action<TEventArgs>> addHandler, Action<Action<TEventArgs>> removeHandler) |
| 1273 |
{ |
| 1274 |
if (addHandler == null) |
| 1275 |
throw new ArgumentNullException("addHandler"); |
| 1276 |
if (removeHandler == null) |
| 1277 |
throw new ArgumentNullException("removeHandler"); |
| 1278 |
|
| 1279 |
return s_impl.FromEvent<TEventArgs>(addHandler, removeHandler); |
| 1280 |
} |
| 1281 |
|
| 1282 |
/// <summary> |
| 1283 |
/// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 1284 |
/// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead. |
| 1285 |
/// </summary> |
| 1286 |
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> |
| 1287 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 1288 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 1289 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 1290 |
/// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns> |
| 1291 |
/// <exception cref="ArgumentNullException"><paramref name="addHandler"/> or <paramref name="removeHandler"/> or <paramref name="scheduler"/> is null.</exception> |
| 1292 |
/// <remarks> |
| 1293 |
/// <para> |
| 1294 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 1295 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 1296 |
/// </para> |
| 1297 |
/// <para> |
| 1298 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 1299 |
/// accessed from the same context, as required by some UI frameworks. |
| 1300 |
/// </para> |
| 1301 |
/// <para> |
| 1302 |
/// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 1303 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler |
| 1304 |
/// parameter. For more information, see the remarks section on those overloads. |
| 1305 |
/// </para> |
| 1306 |
/// </remarks> |
| 1307 |
/// <seealso cref="Observable.ToEvent"/> |
| 1308 |
public static IObservable<TEventArgs> FromEvent<TEventArgs>(Action<Action<TEventArgs>> addHandler, Action<Action<TEventArgs>> removeHandler, IScheduler scheduler) |
| 1309 |
{ |
| 1310 |
if (addHandler == null) |
| 1311 |
throw new ArgumentNullException("addHandler"); |
| 1312 |
if (removeHandler == null) |
| 1313 |
throw new ArgumentNullException("removeHandler"); |
| 1314 |
if (scheduler == null) |
| 1315 |
throw new ArgumentNullException("scheduler"); |
| 1316 |
|
| 1317 |
return s_impl.FromEvent<TEventArgs>(addHandler, removeHandler, scheduler); |
| 1318 |
} |
| 1319 |
|
| 1320 |
#endregion |
| 1321 |
|
| 1322 |
#region Action<Action> |
| 1323 |
|
| 1324 |
/// <summary> |
| 1325 |
/// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 1326 |
/// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead. |
| 1327 |
/// </summary> |
| 1328 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 1329 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 1330 |
/// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns> |
| 1331 |
/// <exception cref="ArgumentNullException"><paramref name="addHandler"/> or <paramref name="removeHandler"/> is null.</exception> |
| 1332 |
/// <remarks> |
| 1333 |
/// <para> |
| 1334 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 1335 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 1336 |
/// </para> |
| 1337 |
/// <para> |
| 1338 |
/// The current <see cref="SynchronizationContext"/> is captured during the call to FromEvent, and is used to post add and remove handler invocations. |
| 1339 |
/// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks. |
| 1340 |
/// </para> |
| 1341 |
/// <para> |
| 1342 |
/// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread |
| 1343 |
/// making the Subscribe or Dispose call, respectively. |
| 1344 |
/// </para> |
| 1345 |
/// <para> |
| 1346 |
/// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so |
| 1347 |
/// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions |
| 1348 |
/// more concise and easier to understand. |
| 1349 |
/// </para> |
| 1350 |
/// </remarks> |
| 1351 |
/// <seealso cref="Observable.ToEvent"/> |
| 1352 |
public static IObservable<Unit> FromEvent(Action<Action> addHandler, Action<Action> removeHandler) |
| 1353 |
{ |
| 1354 |
if (addHandler == null) |
| 1355 |
throw new ArgumentNullException("addHandler"); |
| 1356 |
if (removeHandler == null) |
| 1357 |
throw new ArgumentNullException("removeHandler"); |
| 1358 |
|
| 1359 |
return s_impl.FromEvent(addHandler, removeHandler); |
| 1360 |
} |
| 1361 |
|
| 1362 |
/// <summary> |
| 1363 |
/// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence. |
| 1364 |
/// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead. |
| 1365 |
/// </summary> |
| 1366 |
/// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param> |
| 1367 |
/// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param> |
| 1368 |
/// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> |
| 1369 |
/// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns> |
| 1370 |
/// <exception cref="ArgumentNullException"><paramref name="addHandler"/> or <paramref name="removeHandler"/> or <paramref name="scheduler"/> is null.</exception> |
| 1371 |
/// <remarks> |
| 1372 |
/// <para> |
| 1373 |
/// Add and remove handler invocations are made whenever the number of observers grows beyond zero. |
| 1374 |
/// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting. |
| 1375 |
/// </para> |
| 1376 |
/// <para> |
| 1377 |
/// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be |
| 1378 |
/// accessed from the same context, as required by some UI frameworks. |
| 1379 |
/// </para> |
| 1380 |
/// <para> |
| 1381 |
/// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries, |
| 1382 |
/// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler |
| 1383 |
/// parameter. For more information, see the remarks section on those overloads. |
| 1384 |
/// </para> |
| 1385 |
/// </remarks> |
| 1386 |
/// <seealso cref="Observable.ToEvent"/> |
| 1387 |
public static IObservable<Unit> FromEvent(Action<Action> addHandler, Action<Action> removeHandler, IScheduler scheduler) |
| 1388 |
{ |
| 1389 |
if (addHandler == null) |
| 1390 |
throw new ArgumentNullException("addHandler"); |
| 1391 |
if (removeHandler == null) |
| 1392 |
throw new ArgumentNullException("removeHandler"); |
| 1393 |
if (scheduler == null) |
| 1394 |
throw new ArgumentNullException("scheduler"); |
| 1395 |
|
| 1396 |
return s_impl.FromEvent(addHandler, removeHandler, scheduler); |
| 1397 |
} |
| 1398 |
|
| 1399 |
#endregion |
| 1400 |
|
| 1401 |
#endregion |
| 1402 |
} |
| 1403 |
} |