public override void AddTransformer <TIn, TOut>(Guid parentId, FlowTransformerDefinition <TIn, TOut> definition, FlowLinkDefinition <TIn> link) { FlowTransformerSettings settings = (FlowTransformerSettings)definition.Settings; LinkRouterBase <TOut> router = GetLinkFromProducerType <TOut>(settings.ProducerType); if (!_blockContainer.TryGetTransformer(definition.BlockInfo.Id, out TransformerBlock <TIn, TOut> transformer)) { BlockHeader header = new BlockHeader(definition.BlockInfo, Definition.ServiceInfo); TransformerBlockActionBase <TIn, TOut> action = _actionFactory.CreateTransformerAction <TIn, TOut>(definition.ActionType); action.Header = header; action.Context = definition.Settings.Context; definition.Settings.Type = _flowType; definition.Settings.Iterations = _iterations; action.Logger ??= Logger; IBlockLinkReceiver <TIn> receiver = link.LinkFactory.CreateReceiver(link); transformer = new TransformerBlock <TIn, TOut>(header, receiver, router, action, definition); AssignLoggers(transformer); _blockContainer.AddBlock(transformer); } if (_blockContainer.TryGetSourceBlock(parentId, out SourceBlockBase <TIn> parentBlock)) { Link(parentBlock, transformer, link); return; } throw new Exception($"Cannot link block {definition.BlockInfo.Name} with id {definition.BlockInfo.Id} to parent block. " + "Either the parent block or the child block was not found."); }
internal FluentTransformerDefinitionWithAction(BlockInfo blockInfo, FlowTransformerSettings transformerSettings) { _blockInfo = blockInfo; _transformerSettings = transformerSettings; }
internal FlowTransformerDefinition(BlockInfo blockInfo, FlowTransformerSettings settings, Type actionType) : base(blockInfo, settings, actionType, BlockType.Transformer) { }