PipeContent.cs 860 B

1234567891011121314151617181920212223
  1. using Autofac;
  2. namespace SHJX.Service.Control.Pipeline.Contents
  3. {
  4. public class PipeContent
  5. {
  6. private static readonly ConcurrentDictionary<string, IPipeline> pipes = new();
  7. public PipeContent(PipelineConfig pipeConfig, IComponentContext componentContext)
  8. {
  9. pipeConfig.PipelineContents.ForEach(pipeContent =>
  10. {
  11. IPipeline content = componentContext.ResolveNamed<IPipeline>("VirtualPipeline");
  12. pipeContent.Nodes.ForEach(node => content.AddNode(componentContext.ResolveNamed<INode>(node)));
  13. pipes.TryAdd(pipeContent.Alias, content);
  14. });
  15. }
  16. public static IPipeline Factory(string key)
  17. {
  18. return pipes.TryGetValue(key, out IPipeline pipeline) ? pipeline : throw new ArgumentNullException(key);
  19. }
  20. }
  21. }