public static IConnector <T> CreateAndBuild(Action <IConnectorLinker <T> > buildChain, ConnectorContext connectorContext) { var linker = new ConnectorLinker <T>(connectorContext); using var _ = connectorContext.BeginDepth(); buildChain(linker); return(linker.Connector); }
IChain IChainBuilder.BuildChain(IServiceProvider serviceProvider) { var lockStrategy = CreateLockStrategy(); var connectorContext = new ConnectorContext(Name, serviceProvider); var rootConnector = ConnectorLinker <T> .CreateAndBuild(ConfigureRootConnector, connectorContext); var(connectors, initQueue) = connectorContext.Seal(); var sourceConnectorCollection = new SourceConnectorCollection <T>(Name, serviceProvider); ConfigureSources(sourceConnectorCollection); var sourceConnectors = sourceConnectorCollection.ToArray(); return(new Chain <T>(Name, lockStrategy, rootConnector, connectors, sourceConnectors, serviceProvider, initQueue)); }
public static IConnector <TInput, TOutput> Create <TInput, TLink, TOutput>(string?name, ConnectorContext context) where TLink : ILink <TInput, TOutput> { name ??= typeof(TLink).Name; if (typeof(StatefulLink <TInput, TOutput>).IsAssignableFrom(typeof(TLink))) { var singletonConnectorType = typeof(StatefulLinkConnector <, ,>).MakeGenericType(typeof(TInput), typeof(TLink), typeof(TOutput)); return((IConnector <TInput, TOutput>)Activator.CreateInstance(singletonConnectorType, name, context) !); } return(new StatelessLinkConnector <TInput, TLink, TOutput>(name, context)); }
private ConnectorLinker(ConnectorContext context) { _context = context; }