private void RegisterDefaultChannelFBuilders() { var serialChannelFactory = new RegisteredChannelBuilder { IsConnectionStringValid = SerialDeviceEndpoint.IsValidConnectionString, EndpointFromConnectionString = SerialDeviceEndpoint.FromConnectionString, ChannelFromEndpoint = endpoint => new SerialCommunicationChannel(endpoint) }; deviceTypes.Add(serialChannelFactory); }
/// <summary> /// Registers a user-supplied channel implementation with the channel factory. /// </summary> /// <param name="isConnectionStringValid"> /// A predicate that returns <c>true</c> if the supplied connection string /// is valid for the channel. /// </param> /// <param name="createEndpoint"> /// A function that takes a connection string and returns a <see cref="DeviceEndpoint" /> /// appropriate to the channel. /// </param> /// <param name="createChannel"> /// A function that takes a <see cref="DeviceEndpoint" /> and creates and returns /// an <see cref="ICommunicationChannel" /> implementation. /// </param> public void RegisterChannelType( Predicate <string> isConnectionStringValid, Func <string, DeviceEndpoint> createEndpoint, Func <DeviceEndpoint, ICommunicationChannel> createChannel) { var registration = new RegisteredChannelBuilder { IsConnectionStringValid = isConnectionStringValid, EndpointFromConnectionString = createEndpoint, ChannelFromEndpoint = createChannel }; deviceTypes.Add(registration); }