示例#1
0
            protected override object MaterializeAtomic(AtomicModule atomic, Attributes effectiveAttributes,
                                                        IDictionary <IModule, object> materializedValues)
            {
                if (IsDebug)
                {
                    Console.WriteLine($"materializing {atomic}");
                }

                if (atomic is ISinkModule)
                {
                    var    sink = (ISinkModule)atomic;
                    object materialized;
                    var    subscriber = sink.Create(CreateMaterializationContext(effectiveAttributes), out materialized);
                    AssignPort(sink.Shape.Inlets.First(), subscriber);
                    materializedValues.Add(atomic, materialized);
                }
                else if (atomic is ISourceModule)
                {
                    var    source = (ISourceModule)atomic;
                    object materialized;
                    var    publisher = source.Create(CreateMaterializationContext(effectiveAttributes), out materialized);
                    AssignPort(source.Shape.Outlets.First(), publisher);
                    materializedValues.Add(atomic, materialized);
                }
                else if (atomic is IStageModule)
                {
                    // FIXME: Remove this, only stream-of-stream ops need it
                    var stage = (IStageModule)atomic;
                    // assumes BaseType is StageModule<>
                    var methodInfo = ProcessorForMethod.MakeGenericMethod(atomic.GetType().BaseType.GenericTypeArguments);
                    var parameters = new object[]
                    { stage, effectiveAttributes, _materializer.EffectiveSettings(effectiveAttributes), null };
                    var    processor    = methodInfo.Invoke(this, parameters);
                    object materialized = parameters[3];
                    AssignPort(stage.In, UntypedSubscriber.FromTyped(processor));
                    AssignPort(stage.Out, UntypedPublisher.FromTyped(processor));
                    materializedValues.Add(atomic, materialized);
                }
                //else if (atomic is TlsModule)
                //{
                //})
                else if (atomic is GraphModule)
                {
                    var graph = (GraphModule)atomic;
                    MaterializeGraph(graph, effectiveAttributes, materializedValues);
                }
                else if (atomic is GraphStageModule)
                {
                    var stage = (GraphStageModule)atomic;
                    var graph =
                        new GraphModule(
                            GraphAssembly.Create(stage.Shape.Inlets, stage.Shape.Outlets, new[] { stage.Stage }),
                            stage.Shape, stage.Attributes, new IModule[] { stage });
                    MaterializeGraph(graph, effectiveAttributes, materializedValues);
                }

                return(NotUsed.Instance);
            }
示例#2
0
            protected override object MaterializeAtomic(AtomicModule atomic, Attributes effectiveAttributes,
                                                        IDictionary <IModule, object> materializedValues)
            {
                if (IsDebug)
                {
                    Console.WriteLine($"materializing {atomic}");
                }

                if (atomic is ISinkModule)
                {
                    var    sink = (ISinkModule)atomic;
                    object materialized;
                    var    subscriber = sink.Create(CreateMaterializationContext(effectiveAttributes), out materialized);
                    AssignPort(sink.Shape.Inlets.First(), subscriber);
                    materializedValues.Add(atomic, materialized);
                }
                else if (atomic is ISourceModule)
                {
                    var    source = (ISourceModule)atomic;
                    object materialized;
                    var    publisher = source.Create(CreateMaterializationContext(effectiveAttributes), out materialized);
                    AssignPort(source.Shape.Outlets.First(), publisher);
                    materializedValues.Add(atomic, materialized);
                }
                else if (atomic is IProcessorModule)
                {
                    var stage        = atomic as IProcessorModule;
                    var t            = stage.CreateProcessor();
                    var processor    = t.Item1;
                    var materialized = t.Item2;

                    AssignPort(stage.In, UntypedSubscriber.FromTyped(processor));
                    AssignPort(stage.Out, UntypedPublisher.FromTyped(processor));
                    materializedValues.Add(atomic, materialized);
                }
                //else if (atomic is TlsModule)
                //{
                //})
                else if (atomic is GraphModule)
                {
                    var graph = (GraphModule)atomic;
                    MaterializeGraph(graph, effectiveAttributes, materializedValues);
                }
                else if (atomic is GraphStageModule)
                {
                    var stage = (GraphStageModule)atomic;
                    var graph =
                        new GraphModule(
                            GraphAssembly.Create(stage.Shape.Inlets, stage.Shape.Outlets, new[] { stage.Stage }),
                            stage.Shape, stage.Attributes, new IModule[] { stage });
                    MaterializeGraph(graph, effectiveAttributes, materializedValues);
                }

                return(NotUsed.Instance);
            }
示例#3
0
            protected override object MaterializeAtomic(AtomicModule atomic, Attributes effectiveAttributes, IDictionary <IModule, object> materializedValues)
            {
                foreach (var inPort in atomic.InPorts)
                {
                    var subscriber = new TestSubscriber(atomic, inPort);
                    Subscribers = Subscribers.Add(subscriber);
                    AssignPort(inPort, UntypedSubscriber.FromTyped(subscriber));
                }
                foreach (var outPort in atomic.OutPorts)
                {
                    var publisher = new TestPublisher(atomic, outPort);
                    Publishers = Publishers.Add(publisher);
                    AssignPort(outPort, UntypedPublisher.FromTyped(publisher));
                }

                return(NotUsed.Instance);
            }