Esempio n. 1
0
 /// <summary>
 /// Converts this Flow to a <see cref="IRunnableGraph{TMat}"/> that materializes to a Reactive Streams <see cref="IProcessor{T1,T2}"/>
 /// which implements the operations encapsulated by this Flow. Every materialization results in a new Processor
 /// instance, i.e. the returned <see cref="IRunnableGraph{TMat}"/> is reusable.
 /// </summary>
 /// <returns>A <see cref="IRunnableGraph{TMat}"/> that materializes to a <see cref="IProcessor{T1,T2}"/> when Run() is called on it.</returns>
 public IRunnableGraph <IProcessor <TIn, TOut> > ToProcessor()
 => Source.AsSubscriber <TIn>()
 .Via(this)
 .ToMaterialized(Sink.AsPublisher <TOut>(false), Keep.Both)
 .MapMaterializedValue(t => new FlowProcessor <TIn, TOut>(t.Item1, t.Item2) as IProcessor <TIn, TOut>);
Esempio n. 2
0
        /// <summary>
        ///  Materializes this Source immediately.
        /// </summary>
        /// <param name="materializer">The materializer.</param>
        /// <returns>A tuple containing the (1) materialized value and (2) a new <see cref="Source"/>
        ///  that can be used to consume elements from the newly materialized <see cref="Source"/>.</returns>
        public Tuple <TMat, Source <TOut, NotUsed> > PreMaterialize(IMaterializer materializer)
        {
            var tup = ToMaterialized(Sink.AsPublisher <TOut>(fanout: true), Keep.Both).Run(materializer);

            return(Tuple.Create(tup.Item1, Source.FromPublisher(tup.Item2)));
        }