public void AddUsbDevice(UsbDeviceInformation device) { if (UsbDeviceIsPresent(device)) { throw new InvalidOperationException(String.Format("Device {0} is already added", device)); } devices.Add(device); }
public Boolean UsbDeviceIsPresent(UsbDeviceInformation device) { foreach (UsbDeviceInformation deviceInList in devices) { if (device.Equals(deviceInList)) { return(true); } } return(false); }
public void RemoveUsbDevice(UsbDeviceInformation device) { for (int i = 0; i < devices.Count; i++) { if (device.Equals(devices[i])) { devices.RemoveAt(i); return; } } throw new InvalidOperationException(String.Format("Device {0} is not present", device)); }
static void RawControlExample(EndPoint serverEndPoint) { NpcClient npcClient = new NpcClient(serverEndPoint); npcClient.UpdateAndVerifyEnumAndObjectTypes(); /* * npcClient.VerifyMethodDefinitions(false, new SosMethodDefinition[] { * new SosMethodDefinition("UsbImpl.GetDevices", "UsbDeviceInformation[]"), * new SosMethodDefinition("UsbImpl.AddUsbDevice", "Void", "UsbDeviceInformation", "device"), * }); */ // // Call Example 1 // UInt32 id = (UInt32)npcClient.Call("testnamespace.device.getid"); Console.WriteLine("id is {0}", id); npcClient.Call("testnamespace.device.setid", 293); // // Call Example 2 (using namespace client) // This means that you can just call the method name instead of providing the whole namespace/class // NpcClientNamespaceCaller npcNamespaceClient = new NpcClientNamespaceCaller(npcClient, "testnamespace.device"); id = (UInt32)npcNamespaceClient.Call("getid"); Console.WriteLine("id is {0}", id); npcClient.Dispose(); UsbDeviceInformation deviceInfo = new UsbDeviceInformation(UsbLegacyName.CAT, 24, "Manufacturer\nwith newline"); npcClient.Call("UsbImpl.AddUsbDevice", deviceInfo); deviceInfo.legacyName = UsbLegacyName.KBD; deviceInfo.@class = 88; deviceInfo.manufacturer = "HP INC"; npcClient.Call("UsbImpl.AddUsbDevice", deviceInfo); UsbDeviceInformation[] deviceInfos = (UsbDeviceInformation[])npcClient.Call("UsbImpl.GetDevices"); }
public Boolean Equals(UsbDeviceInformation device) { return(this.legacyName == device.legacyName && this.@class == device.@class && this.manufacturer.Equals(device.manufacturer)); }
/// <summary>The UsbDeviceIsPresent method</summary> /// <param name="device">The device parameter of type UsbDeviceInformation</param> /// <returns>Return type is Boolean</returns> public Boolean UsbDeviceIsPresent(UsbDeviceInformation device) { return((Boolean)npcClientCaller.Call(typeof(Boolean), "UsbImpl.UsbDeviceIsPresent", device)); }
/// <summary>The RemoveUsbDevice method</summary> /// <param name="device">The device parameter of type UsbDeviceInformation</param> public void RemoveUsbDevice(UsbDeviceInformation device) { npcClientCaller.Call(typeof(void), "UsbImpl.RemoveUsbDevice", device); }