/// <summary> /// TBD /// </summary> /// <param name="subscriber">TBD</param> /// <param name="subscription">TBD</param> /// <exception cref="SignalThrewException">TBD</exception> internal static void TryOnSubscribe(IUntypedSubscriber subscriber, ISubscription subscription) { try { subscriber.OnSubscribe(subscription); } catch (Exception e) { throw new SignalThrewException($"{subscriber}.OnSubscribe", e); } }
/// <summary> /// TBD /// </summary> /// <param name="subscriber">TBD</param> /// <exception cref="SignalThrewException">TBD</exception> internal static void TryOnComplete(IUntypedSubscriber subscriber) { try { subscriber.OnComplete(); } catch (Exception e) { throw new SignalThrewException($"{subscriber}.OnComplete", e); } }
/// <summary> /// TBD /// </summary> /// <param name="subscriber">TBD</param> /// <param name="element">TBD</param> /// <exception cref="SignalThrewException">TBD</exception> internal static void TryOnNext(IUntypedSubscriber subscriber, object element) { RequireNonNullElement(element); try { subscriber.OnNext(element); } catch (Exception e) { throw new SignalThrewException($"{subscriber}.OnNext", e); } }
private void SubscribePending(IEnumerable <IUntypedSubscriber> subscribers) { foreach (var subscriber in subscribers) { if (ReferenceEquals(Subscriber, null)) { Subscriber = subscriber; ReactiveStreamsCompliance.TryOnSubscribe(subscriber, CreateSubscription()); } else { ReactiveStreamsCompliance.RejectAdditionalSubscriber(subscriber, GetType().Name); } } }
/// <summary> /// TBD /// </summary> /// <param name="subscriber">TBD</param> /// <param name="cause">TBD</param> /// <exception cref="IllegalStateException">TBD</exception> /// <exception cref="SignalThrewException">TBD</exception> internal static void TryOnError(IUntypedSubscriber subscriber, Exception cause) { if (cause is ISpecViolation) { throw new IllegalStateException("It's illegal to try to signal OnError with a spec violation", cause); } try { subscriber.OnError(cause); } catch (Exception e) { throw new SignalThrewException($"{subscriber}.OnError", e); } }
/// <summary> /// TBD /// </summary> /// <param name="subscriber">TBD</param> public abstract void Subscribe(IUntypedSubscriber subscriber);
/// <summary> /// TBD /// </summary> /// <param name="subscriber">TBD</param> public override void Subscribe(IUntypedSubscriber subscriber) { _publisher.Subscribe(UntypedSubscriber.ToTyped <T>(subscriber)); }
/// <summary> /// TBD /// </summary> /// <param name="subscriber">TBD</param> /// <param name="rejector">TBD</param> internal static void RejectAdditionalSubscriber(IUntypedSubscriber subscriber, string rejector) { TryOnSubscribe(subscriber, CancelledSubscription.Instance); TryOnError(subscriber, new IllegalStateException(rejector + " " + SupportsOnlyASingleSubscriber)); }
/// <summary> /// TBD /// </summary> /// <typeparam name="T">TBD</typeparam> /// <param name="untypedSubscriber">TBD</param> /// <returns>TBD</returns> public static ISubscriber <T> ToTyped <T>(IUntypedSubscriber untypedSubscriber) { return((ISubscriber <T>)ToTyped(untypedSubscriber)); }
/// <summary> /// TBD /// </summary> /// <param name="subscriber">TBD</param> /// <param name="demand">TBD</param> /// <param name="lifecycleState">TBD</param> public State(IUntypedSubscriber subscriber, long demand, LifecycleState lifecycleState) { Subscriber = subscriber; Demand = demand; LifecycleState = lifecycleState; }