Beispiel #1
0
        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));
        }
Beispiel #2
0
            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();
            }
        }
Beispiel #5
0
 public ToTypedMultiSubject(IMultiSubject innerSubject)
 {
     _innerSubject = innerSubject;
 }
Beispiel #6
0
 public PartitionedMulticaster()
 {
     _partitions = new RefCountingDictionary <object, Partition>();
     _default    = new SimpleSubject <T>();
 }
Beispiel #7
0
 /// <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));
 }
Beispiel #8
0
 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);
Beispiel #10
0
 public GroupedMultiSubject(IMultiSubject <TSource, TSource> subject, TKey key)
 {
     _subject = subject;
     _key     = key;
 }