示例#1
0
        public static bool TryParseHueDeviceType(HueDeviceDto hueDevice, out EHueDeviceType deviceType)
        {
            if (!string.IsNullOrEmpty(hueDevice.Type))
            {
                bool result = false;
                switch (hueDevice.Type)
                {
                case LightType_ColorTemperatureLight:
                    deviceType = EHueDeviceType.Temperature_Light;
                    result     = true;
                    break;

                case LightType_ExtendedColorLight:
                    deviceType = EHueDeviceType.Extended_Color_Light;
                    result     = true;
                    break;

                default:
                    deviceType = EHueDeviceType.Unkown;
                    result     = false;
                    break;
                }


                return(result);
            }

            else
            {
                deviceType = EHueDeviceType.Unkown;
                return(false);
            }
        }
示例#2
0
        private object MapToType(EHueDeviceType deviceType, HueLightStatePutDto state, bool withoutOn)
        {
            object contentDto = null;

            switch (deviceType)
            {
            case EHueDeviceType.Extended_Color_Light:
                contentDto = withoutOn ? (object)this._mapper.Map <ExtendedColorLightWithoutOnPutDto>(state) : this._mapper.Map <ExtendedColorLightStatePutDto>(state);
                break;

            case EHueDeviceType.Temperature_Light:
                contentDto = withoutOn ? (object)this._mapper.Map <ColorTemperaturWithoutOnPutDto>(state) :  this._mapper.Map <ColorTemperatureLightPutStateDto>(state);
                break;

            default:
                contentDto = null;
                break;
            }

            return(contentDto);
        }