From 223f5cef14b94ba94492dc0e50a3e6c4db6fc9b6 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 11 Feb 2020 16:00:17 -0700 Subject: [PATCH] Updated the factory device load snippet to include BridgeFactory --- Essentials-Architecture.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Essentials-Architecture.md b/Essentials-Architecture.md index 2e942cb..5f1b1e5 100644 --- a/Essentials-Architecture.md +++ b/Essentials-Architecture.md @@ -122,21 +122,21 @@ This ordering ensures that all devices are at least present before building tie In each device/room step, a device factory process is called. We call subsequent device factory methods in the various libraries that make up Essentials until one of them returns a functional device. This allows us to break up the factory process into individual libraries, and not have a huge master list of types and build procedures. Here's part of the code: ``` -// Try local factory first -var newDev = DeviceFactory.GetDevice(devConf); - -// Then associated library factories -if (newDev == null) - newDev = PepperDash.Essentials.Devices.Common.DeviceFactory.GetDevice(devConf); -if (newDev == null) - newDev = PepperDash.Essentials.DM.DeviceFactory.GetDevice(devConf); -if (newDev == null) - newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf); - -if (newDev != null) - DeviceManager.AddDevice(newDev); -else - Debug.Console(0, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key); +// Try local factories first + var newDev = DeviceFactory.GetDevice(devConf); + + if (newDev == null) + newDev = BridgeFactory.GetDevice(devConf); + + // Then associated library factories + if (newDev == null) + newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf); + if (newDev == null) + newDev = PepperDash.Essentials.Devices.Common.DeviceFactory.GetDevice(devConf); + if (newDev == null) + newDev = PepperDash.Essentials.DM.DeviceFactory.GetDevice(devConf); + if (newDev == null) + newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf); ``` In each respective factory, or device constructor, the config's properties object is either converted to a config object or read from using `JToken` methods. This builds the device which may be ready to go, or may require activation as described above.