public bool CreatePipeline <TToken>(string name, Type[] stepsSequence, IPipeline <TToken>[]?steps = null) where TToken : class, new() { Log.Log(MethodBase.GetCurrentMethod() !.Name, $"{name} {typeof(TToken)} {stepsSequence.Length} {steps?.Length}"); if (!_PipelinesList.TryAdd(name, new List <NamePipeline>())) { return(false); } foreach (Type Type in stepsSequence) { IPipeline <TToken>?Pipeline = steps?.FirstOrDefault(s => s.GetType().IsAssignableFrom(typeof(IPipeline <TToken>))); if (Pipeline == null) { Pipeline = Type.GetConstructors()[0].GetParameters().Length == 1 ? (IPipeline <TToken>?)Activator.CreateInstance(Type, this) : (IPipeline <TToken>?)Activator.CreateInstance(Type); Log.Log(MethodBase.GetCurrentMethod() !.Name, $"{name} {Type} created"); } if (Pipeline != null) { _PipelinesList[name].Add(new NamePipeline(name, Pipeline)); } } return(_PipelinesList[name].Count == stepsSequence.Count()); }