Esempio n. 1
0
        public IRelayConnector Connect(IRelayInput input, IRelayOutput output)
        {
            if (input == null || output == null)
            {
                return(null);
            }

            var iKey = input.Name ?? string.Empty;
            var oKey = output.Name ?? string.Empty;

            if (!_inputInitializer.TryGetValue(iKey, out var inputInitializer))
            {
                _inputInitializer.Add(iKey, inputInitializer = new InputInitializer(iKey, input, _queue, RemoveInputInitializer));
            }

            if (!_outputInitializer.TryGetValue(oKey, out var outputInitializer))
            {
                _outputInitializer.Add(oKey, outputInitializer = new OutputInitializer(oKey, output, RemoveOutputInitializer));
            }

            var key = $"{iKey}-{oKey}";

            if (!_connectors.TryGetValue(key, out var connector))
            {
                _connectors.Add(key, connector = new RelayConnector(key, inputInitializer, outputInitializer, _lazyInitializer, RemoveConnector));
            }

            return(connector);
        }
Esempio n. 2
0
 private void RemoveInputInitializer(InputInitializer input)
 => _inputInitializer.Remove(input.Key);