Esempio n. 1
0
        /// <summary>
        /// Builds the query string for the request
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        protected string BuildQueryString(int deviceId, Scope scope, SeriesType seriesType, bool humanReadable, DateTime startDate, DateTime endDate, List <Channel> channels, DeviceClass deviceClass)
        {
            if (channels.Count == 0)
            {
                throw new ArgumentNullException(nameof(channels), "You must provide atleast one channel");
            }


            string channelParam = "";

            if (channels.Count > 1)
            {
                foreach (Channel channel in channels)
                {
                    channelParam = $"{channelParam}&Channel={channel.ToString()}";
                }
            }
            else
            {
                channelParam = $"Channel={channels[0].ToString()}";
            }

            // Only need device class if we are scoped to device
            string deviceClassParam = "";

            if (scope == Scope.Device)
            {
                deviceClassParam = $"&DeviceClass={deviceClass.ToString()}";
            }

            return($"?Scope={scope}&StartDate={startDate.ToString("d.M.yyyy")}&EndDate={endDate.ToString("d.M.yyyy")}&HumanReadable={humanReadable.ToString()}&SeriesType={seriesType.ToString()}{deviceClassParam}" +
                   $"&{channelParam}");
        }
        public void Should_return_DeviceType_from_Name(
            [AllEnumValues(typeof(DeviceClass))] DeviceClass deviceClass)
        {
            var expected = deviceClass.ToString();
            var result   = BluetoothDeviceType.Create(deviceClass);

            Assert.AreEqual(expected, result.Name);
        }
Esempio n. 3
0
        /// <summary>
        /// Constructor for DeviceStatusMonitor.  Specifies
        /// the class of notifications desired and whether
        /// notifications should be fired for already-attached
        /// devices.
        /// </summary>
        /// <param name="deviceClass">
        /// Device class to monitor.
        /// </param>
        /// <param name="notifyAlreadyConnectedDevices">
        /// Set to true to receive notifiations for devices
        /// which were attached before we started monitoring;
        /// set to false to see new events only.
        /// </param>
        public DeviceStatusMonitor(DeviceClass deviceClass, bool notifyAlreadyConnectedDevices)
        {
            object[] attribs = deviceClass.GetType().GetField(deviceClass.ToString()).GetCustomAttributes(typeof(DeviceClassAtrribute), false);
            if ((attribs == null) || (attribs.Length != 1))
            {
                throw new ArgumentException("Unknown Device Class");
            }

            DeviceClassAtrribute dca = attribs[0] as DeviceClassAtrribute;

            m_deviceClass = dca.Guid;
            m_fAll        = notifyAlreadyConnectedDevices;
        }
Esempio n. 4
0
 public string GetHashString()
 {
     return(HashGenerator.GetHashSHA256(DeviceClass.ToString()));
 }
        /// <summary>
        /// This is an helper method to verify device class classification.
        /// </summary>
        /// <param name="deviceClass">The deviceClass<see cref="DeviceClass"/></param>
        /// <param name="human">If the device is used by a human (like  a browser)</param>
        /// <param name="mobile">If the device is mobile</param>
        /// <param name="normal">If its a normal consumer device.</param>
        /// <param name="misuse">If this user agent is a misuse like an hacker.</param>
        private void VerifyDeviceClass(DeviceClass deviceClass, bool human, bool mobile, bool normal, bool misuse)
        {
            var userAgent = new UserAgent();

            userAgent.Set(UserAgent.DEVICE_CLASS, deviceClass.GetValue(), 1);
            UserAgentClassifier.IsHuman(userAgent).Should().Be(human, "For the DeviceClass " + deviceClass.ToString() + " the isHuman() should be correct");
            UserAgentClassifier.IsMobile(userAgent).Should().Be(mobile, "For the DeviceClass " + deviceClass.ToString() + " the isMobile() should be correct");
            UserAgentClassifier.IsNormalConsumerDevice(userAgent).Should().Be(normal, "For the DeviceClass " + deviceClass.ToString() + " the isNormalConsumerDevice() should be correct");
            UserAgentClassifier.IsDeliberateMisuse(userAgent).Should().Be(misuse, "For the DeviceClass " + deviceClass.ToString() + " the isDeliberateMisuse() should be correct");
        }
 public static BluetoothDeviceType Create(DeviceClass deviceClass)
 {
     switch (deviceClass)
     {
         //Phones
         case DeviceClass.Phone:
         case DeviceClass.CellPhone:
         case DeviceClass.CordlessPhone:
         case DeviceClass.SmartPhone:
         case DeviceClass.WiredPhone:
             return new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.PhoneIconUri, true, 1);
         //Computers
         case DeviceClass.Computer:
         case DeviceClass.DesktopComputer:
         case DeviceClass.ServerComputer:
         case DeviceClass.LaptopComputer:
         case DeviceClass.HandheldComputer:
         case DeviceClass.PdaComputer:
         case DeviceClass.WearableComputer:
             return new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.ComputerIconUri, false, 2);
         //Network
         case DeviceClass.IsdnAccess:
         case DeviceClass.AccessPointAvailable:
         case DeviceClass.AccessPoint1To17:
         case DeviceClass.AccessPoint17To33:
         case DeviceClass.AccessPoint33To50:
         case DeviceClass.AccessPoint50To67:
         case DeviceClass.AccessPoint67To83:
         case DeviceClass.AccessPoint83To99:
         case DeviceClass.AccessPointNoService:
             return new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.NetworkIconUri, false, 3);
         //AV
         case DeviceClass.AudioVideoUnclassified:
         case DeviceClass.AudioVideoHeadset:
         case DeviceClass.AudioVideoHandsFree:
         case DeviceClass.AudioVideoMicrophone:
         case DeviceClass.AudioVideoLoudSpeaker:
         case DeviceClass.AudioVideoHeadphones:
         case DeviceClass.AudioVideoPortable:
         case DeviceClass.AudioVideoCar:
         case DeviceClass.AudioVideoSetTopBox:
         case DeviceClass.AudioVideoHiFi:
         case DeviceClass.AudioVideoVcr:
         case DeviceClass.AudioVideoVideoCamera:
         case DeviceClass.AudioVideoCamcorder:
         case DeviceClass.AudioVideoMonitor:
         case DeviceClass.AudioVideoDisplayLoudSpeaker:
         case DeviceClass.AudioVideoVideoConferencing:
         case DeviceClass.AudioVideoGaming:
             return new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.AudioVisualIconUri, false, 3);
         //Peripheral/Accessories
         case DeviceClass.Peripheral:
         case DeviceClass.PeripheralJoystick:
         case DeviceClass.PeripheralGamepad:
         case DeviceClass.PeripheralRemoteControl:
         case DeviceClass.PeripheralSensingDevice:
         case DeviceClass.PeripheralDigitizerTablet:
         case DeviceClass.PeripheralCardReader:
         case DeviceClass.PeripheralKeyboard:
         case DeviceClass.PeripheralPointingDevice:
         case DeviceClass.PeripheralCombinedKeyboardPointingDevice:
             return new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.PeripheralIconUri, false, 3);
         //Imaging/Printers/Cameras
         case DeviceClass.Imaging:
         case DeviceClass.ImagingDisplay:
         case DeviceClass.ImagingCamera:
         case DeviceClass.ImagingScanner:
         case DeviceClass.ImagingPrinter:
             return new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.ImagingIconUri, false, 3);
         ////Wearable
         //case DeviceClass.Wearable:
         //case DeviceClass.WearableWristWatch:
         //case DeviceClass.WearablePager:
         //case DeviceClass.WearableJacket:
         //case DeviceClass.WearableHelmet:
         //case DeviceClass.WearableGlasses:
         ////Toys
         //case DeviceClass.Toy:
         //case DeviceClass.ToyRobot:
         //case DeviceClass.ToyVehicle:
         //case DeviceClass.ToyFigure:
         //case DeviceClass.ToyController:
         //case DeviceClass.ToyGame:
         ////Medical
         //case DeviceClass.Medical:
         //case DeviceClass.MedicalBloodPressureMonitor:
         //case DeviceClass.MedicalThermometer:
         //case DeviceClass.MedicalWeighingScale:
         //case DeviceClass.MedicalGlucoseMeter:
         //case DeviceClass.MedicalPulseOximeter:
         //case DeviceClass.MedicalHeartPulseRateMonitor:
         //case DeviceClass.MedicalDataDisplay:
         ////Other/Unknown
         //case DeviceClass.Uncategorized:
         //case DeviceClass.Miscellaneous:
         default:
             return new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.MiscellaneousIconUri, false, 3);
     }
 }
        public static BluetoothDeviceType Create(DeviceClass deviceClass)
        {
            switch (deviceClass)
            {
            //Phones
            case DeviceClass.Phone:
            case DeviceClass.CellPhone:
            case DeviceClass.CordlessPhone:
            case DeviceClass.SmartPhone:
            case DeviceClass.WiredPhone:
                return(new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.PhoneIconUri, true, 1));

            //Computers
            case DeviceClass.Computer:
            case DeviceClass.DesktopComputer:
            case DeviceClass.ServerComputer:
            case DeviceClass.LaptopComputer:
            case DeviceClass.HandheldComputer:
            case DeviceClass.PdaComputer:
            case DeviceClass.WearableComputer:
                return(new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.ComputerIconUri, false, 2));

            //Network
            case DeviceClass.IsdnAccess:
            case DeviceClass.AccessPointAvailable:
            case DeviceClass.AccessPoint1To17:
            case DeviceClass.AccessPoint17To33:
            case DeviceClass.AccessPoint33To50:
            case DeviceClass.AccessPoint50To67:
            case DeviceClass.AccessPoint67To83:
            case DeviceClass.AccessPoint83To99:
            case DeviceClass.AccessPointNoService:
                return(new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.NetworkIconUri, false, 3));

            //AV
            case DeviceClass.AudioVideoUnclassified:
            case DeviceClass.AudioVideoHeadset:
            case DeviceClass.AudioVideoHandsFree:
            case DeviceClass.AudioVideoMicrophone:
            case DeviceClass.AudioVideoLoudSpeaker:
            case DeviceClass.AudioVideoHeadphones:
            case DeviceClass.AudioVideoPortable:
            case DeviceClass.AudioVideoCar:
            case DeviceClass.AudioVideoSetTopBox:
            case DeviceClass.AudioVideoHiFi:
            case DeviceClass.AudioVideoVcr:
            case DeviceClass.AudioVideoVideoCamera:
            case DeviceClass.AudioVideoCamcorder:
            case DeviceClass.AudioVideoMonitor:
            case DeviceClass.AudioVideoDisplayLoudSpeaker:
            case DeviceClass.AudioVideoVideoConferencing:
            case DeviceClass.AudioVideoGaming:
                return(new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.AudioVisualIconUri, false, 3));

            //Peripheral/Accessories
            case DeviceClass.Peripheral:
            case DeviceClass.PeripheralJoystick:
            case DeviceClass.PeripheralGamepad:
            case DeviceClass.PeripheralRemoteControl:
            case DeviceClass.PeripheralSensingDevice:
            case DeviceClass.PeripheralDigitizerTablet:
            case DeviceClass.PeripheralCardReader:
            case DeviceClass.PeripheralKeyboard:
            case DeviceClass.PeripheralPointingDevice:
            case DeviceClass.PeripheralCombinedKeyboardPointingDevice:
                return(new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.PeripheralIconUri, false, 3));

            //Imaging/Printers/Cameras
            case DeviceClass.Imaging:
            case DeviceClass.ImagingDisplay:
            case DeviceClass.ImagingCamera:
            case DeviceClass.ImagingScanner:
            case DeviceClass.ImagingPrinter:
                return(new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.ImagingIconUri, false, 3));

            ////Wearable
            //case DeviceClass.Wearable:
            //case DeviceClass.WearableWristWatch:
            //case DeviceClass.WearablePager:
            //case DeviceClass.WearableJacket:
            //case DeviceClass.WearableHelmet:
            //case DeviceClass.WearableGlasses:
            ////Toys
            //case DeviceClass.Toy:
            //case DeviceClass.ToyRobot:
            //case DeviceClass.ToyVehicle:
            //case DeviceClass.ToyFigure:
            //case DeviceClass.ToyController:
            //case DeviceClass.ToyGame:
            ////Medical
            //case DeviceClass.Medical:
            //case DeviceClass.MedicalBloodPressureMonitor:
            //case DeviceClass.MedicalThermometer:
            //case DeviceClass.MedicalWeighingScale:
            //case DeviceClass.MedicalGlucoseMeter:
            //case DeviceClass.MedicalPulseOximeter:
            //case DeviceClass.MedicalHeartPulseRateMonitor:
            //case DeviceClass.MedicalDataDisplay:
            ////Other/Unknown
            //case DeviceClass.Uncategorized:
            //case DeviceClass.Miscellaneous:
            default:
                return(new BluetoothDeviceType(deviceClass.ToString(), BluetoothImages.MiscellaneousIconUri, false, 3));
            }
        }