Beispiel #1
0
        public void AddDeviceFactory <TConnectionConfiguration, TDevice>(IConnectedDeviceFactory <TConnectionConfiguration, TDevice> connectedDeviceFactory)
            where TConnectionConfiguration : notnull
            where TDevice : IConnectedDevice
        {
            if (connectedDeviceFactory == null)
            {
                throw new ArgumentNullException(nameof(connectedDeviceFactory));
            }

            _deviceFactories.Add(typeof(IConnectedDeviceFactory <TConnectionConfiguration, TDevice>), connectedDeviceFactory);
            _disposables.Add(connectedDeviceFactory);
        }
Beispiel #2
0
        public void AddDeviceFactory <TConnectionConfiguration, TDevice>(IConnectedDeviceFactory <TConnectionConfiguration, TDevice> connectedDeviceFactory)
            where TConnectionConfiguration : notnull
            where TDevice : IConnectedDevice
        {
            using var operation = Log.OnEnterAndConfirmOnExit();
            if (connectedDeviceFactory == null)
            {
                throw new ArgumentNullException(nameof(connectedDeviceFactory));
            }

            _deviceFactories.Add(typeof(IConnectedDeviceFactory <TConnectionConfiguration, TDevice>), connectedDeviceFactory);
            _disposables.Add(connectedDeviceFactory);
            operation.Succeed();
        }
        public static T GetOrCreateCamera <T>(this PiTopModule module, FileSystemCameraSettings settings) where T : FileSystemCamera
        {
            IConnectedDeviceFactory <FileSystemCameraSettings, FileSystemCamera> factory = null !;

            try
            {
                factory = module.GetDeviceFactory <FileSystemCameraSettings, FileSystemCamera>();
            }
            catch (KeyNotFoundException

                   )
            {
            }

            AssertFactory(factory);
            return(factory.GetOrCreateDevice <T>(settings));
        }
        public static T GetOrCreateCamera <T>(this PiTopModule module, int index)
            where T : ICamera
        {
            IConnectedDeviceFactory <int, ICamera> factory = null !;

            try
            {
                factory = module.GetDeviceFactory <int, ICamera>();
            }
            catch (KeyNotFoundException

                   )
            {
            }

            AssertFactory(factory);
            return(factory.GetOrCreateDevice <T>(index));
        }