public bool TryGetSubject <TInput, TOutput>(Uri uri, out IMultiSubject <TInput, TOutput> subject) { if (!Subjects.TryGetValue(uri.ToCanonicalString(), out SubjectEntity entity)) { subject = null; return(false); } switch (entity.Instance) { case IMultiSubject <TInput, TOutput> result: subject = result; return(true); case IDynamicMultiSubject dyn: subject = dyn.ToTyped <TInput, TOutput>(); return(true); case IMultiSubject untyped: subject = untyped.ToTyped <TInput, TOutput>(); return(true); } throw InvalidInstance("Subject", uri, typeof(IMultiSubject <TInput, TOutput>), nameof(uri)); }
protected override IGroupedSubscribable <TKey, TElement> Quote(IMultiSubject <TElement, TElement> inner, Uri innerStreamUri) { var group = (IGroupedMultiSubject <TKey, TElement>)inner; if (TryGetHigherOrderExecutionEnvironment(out var env)) { return(env.Quote(group, innerStreamUri)); } return(group); }
/// <summary> /// Tries to get the subject for an inner stream with the specified tunnel URI. /// </summary> /// <param name="innerStreamUri">Tunnel URI of the stream to obtain the subject for.</param> /// <param name="inner">Subject for the inner stream, if found.</param> /// <returns>true if the stream was found; otherwise, false.</returns> protected bool TryGetInner(Uri innerStreamUri, out IMultiSubject <TElement, TElement> inner) { if (HasStopped || innerStreamUri == null) { inner = null; return(false); } inner = Context.ExecutionEnvironment.GetSubject <TElement, TElement>(innerStreamUri); return(true); }
/// <summary> /// Sends the specified inner stream to the downstream observer. /// </summary> /// <param name="inner">Subject for the inner stream to sen to the downstream observer.</param> /// <param name="innerStreamUri">Tunnel URI of the stream; used for quotation.</param> protected void OnNextInner(IMultiSubject <TElement, TElement> inner, Uri innerStreamUri) { var quotedInner = Quote(inner, innerStreamUri); Output.OnNext(quotedInner); // To work around space leaks we'll enforce a synchronous subscription requirement during OnNext for now. // More information in the CreateWindow method. if (inner is ISealable seal) { seal.Seal(); } }
public ToTypedMultiSubject(IMultiSubject innerSubject) { _innerSubject = innerSubject; }
public PartitionedMulticaster() { _partitions = new RefCountingDictionary <object, Partition>(); _default = new SimpleSubject <T>(); }
/// <summary> /// Converts a non-generic multi-subject to the generic variety. /// </summary> /// <typeparam name="TInput">The observer-side type of the subject.</typeparam> /// <typeparam name="TOutput">The observable-side type of the subject.</typeparam> /// <param name="subject">The multi-subject to wrap.</param> /// <returns>The wrapped multi-subject.</returns> public static IMultiSubject <TInput, TOutput> ToTyped <TInput, TOutput>(this IMultiSubject subject) { return(new ToTypedMultiSubject <TInput, TOutput>(subject)); }
public ISubscribable <T> Quote <T>(IMultiSubject <T, T> subject, Uri uri) => HigherOrder.Quote(subject, uri);
/// <summary> /// Quotes the specified subject for an inner stream using the specified tunnel URI. /// </summary> /// <param name="inner">Subject for the inner stream to sen to the downstream observer.</param> /// <param name="innerStreamUri">Tunnel URI of the stream; used for quotation.</param> /// <returns>Quoted representation of the inner stream.</returns> protected abstract TResult Quote(IMultiSubject <TElement, TElement> inner, Uri innerStreamUri);
public GroupedMultiSubject(IMultiSubject <TSource, TSource> subject, TKey key) { _subject = subject; _key = key; }