public GpioControllerOptionsConfigurator(GpioControllerOptions gpioControllerOptions)
        {
            if (gpioControllerOptions == null)
            {
                throw new ArgumentNullException(nameof(gpioControllerOptions));
            }

            _gpioControllerOptions = gpioControllerOptions;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates gpio controller and returns its instance
        /// </summary>
        /// <param name="configurator">Gpio controller configurator <see cref="IGpioControllerOptionsConfigurator"/></param>
        /// <returns>Instance of <see cref="IGpioController"/></returns>
        public IGpioController Create(Action <IGpioControllerOptionsConfigurator> configurator)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var gpioControllerOptions = new GpioControllerOptions();

            configurator(new GpioControllerOptionsConfigurator(gpioControllerOptions));

            // TODO: check if IGpioService is correrct for current for platform type

            if (gpioControllerOptions.GpioService != null)
            {
                return(new GpioController(gpioControllerOptions.GpioService));
            }

            return(gpioControllerOptions.PlatformType == PlatformType.Windows
                ? new GpioController(new WindowsGpioService())
                : new GpioController(new LinuxGpioService()));
        }