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); }
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); }