public static IServiceCollection AddWinLirc(this IServiceCollection services, Action <WinLircConfig> configure) { var options = new WinLircConfig(); configure?.Invoke(options); if (options.Enabled) { services.TryAddSingleton <WinLircConfig>(options); services.TryAddSingleton <IWinLircConnection, WinLircConnection>(); services.TryAddSingleton <IWinLircManager, WinLircManager>(); services.TryAddScoped(typeof(IWinLircSwitchRepository <,>), typeof(WinLircSwitchRepository <,>)); services.AdditionalSwitchConfiguration(o => { o.AddSwitch(typeof(IWinLircSwitchRepository <,>)); }); } return(services); }
/// <summary> /// Constructor /// </summary> /// <param name="manager">The PowerStripManager to use.</param> public WinLircSwitchRepository(IWinLircManager manager, WinLircConfig config) { this.manager = manager; this.config = config; }
public WinLircConnection(WinLircConfig config) { tcpClient = new TcpClient(); tcpClient.Connect(config.Host, config.Port); tcpStream = tcpClient.GetStream(); }