public HmdTypeverifydevicesarenotpresent(HmdBlockID blockID, HmdProperties hmdProperties) { for (int i = 0; i < blockID.ChildCount; i++) { HmdID childID = blockID.GetChild(i); if (childID.isBlock) { HmdBlockID childBlockID = (HmdBlockID)childID; // parse field UsbDevice if (childBlockID.idLowerCase.Equals("usbdevice", StringComparison.CurrentCultureIgnoreCase)) { // set List to not null this.UsbDevice.Add(new HmdTypeusbdevice(childBlockID, hmdProperties)); } else { throw new FormatException(String.Format("Unrecognized child block id \"{0}\"", childID.idOriginalCase)); } } else { HmdValueID childValueID = (HmdValueID)childID; throw new FormatException(String.Format("Unrecognized child value id \"{0}\"", childID.idOriginalCase)); } } }
public static void Iterate(this HmdBlockID blockID, HmdProperties hmdProperties, AtValueIDWithProperties atValueIDWithProperties, AtBlockIDWithProperties atBlockIDWithProperties) { for (int i = 0; i < blockID.ChildCount; i++) { HmdID childID = blockID.GetChild(i); if (childID.isBlock) { HmdBlockID childBlockID = childID.CastAsBlockID; HmdBlockIDProperties childBlockIDProperties = hmdProperties.GetProperties(childBlockID); if (childBlockIDProperties == null) { throw new InvalidOperationException(String.Format("Found a block id \"{0}\", but it was not defined in the property dictionary", childID.idOriginalCase)); } atBlockIDWithProperties(childBlockID, childBlockIDProperties, hmdProperties); } else { HmdValueID childValueID = childID.CastAsValueID; HmdValueIDProperties childValueIDProperties = hmdProperties.GetProperties(childValueID); if (childValueIDProperties == null) { throw new InvalidOperationException(String.Format("Found a value id \"{0}\", but it was not defined in the property dictionary", childID.idOriginalCase)); } atValueIDWithProperties(childValueID, childValueIDProperties, hmdProperties); } } }
public HmdID TryGetChild(String childID) { for (int i = 0; i < children.Count; i++) { HmdID child = children[i]; if (childID.Equals(child.idLowerCase, StringComparison.CurrentCultureIgnoreCase)) { return(child); } } return(null); }
public T GetProperties(HmdID id) { String contextString = id.CreateContextString(); T idProperties = TryGetProperties(contextString); if (idProperties == null) { throw new InvalidOperationException(String.Format("The id \"{0}\" was not found in the defintionDictionary or the extraLinksDictionary (context={1})", id.idOriginalCase, contextString)); } return(idProperties); }
public DefaultRootClassName(HmdBlockID blockID, HmdProperties hmdProperties) { for (int i = 0; i < blockID.ChildCount; i++) { HmdID childID = blockID.GetChild(i); if (childID.isBlock) { HmdBlockID childBlockID = (HmdBlockID)childID; // parse field VerifyDevicesArePresent if (childBlockID.idLowerCase.Equals("verifydevicesarepresent", StringComparison.CurrentCultureIgnoreCase)) { // set List to not null this.VerifyDevicesArePresent.Add(new HmdTypeverifydevicesarepresent(childBlockID, hmdProperties)); } // parse field VerifyDevicesAreNotPresent else if (childBlockID.idLowerCase.Equals("verifydevicesarenotpresent", StringComparison.CurrentCultureIgnoreCase)) { // set List to not null this.VerifyDevicesAreNotPresent.Add(new HmdTypeverifydevicesarenotpresent(childBlockID, hmdProperties)); } else { throw new FormatException(String.Format("Unrecognized child block id \"{0}\"", childID.idOriginalCase)); } } else { HmdValueID childValueID = (HmdValueID)childID; // parse field Message if (childValueID.idLowerCase.Equals("message", StringComparison.CurrentCultureIgnoreCase)) { this.Message.Add(childValueID.value); } // parse field UsbSwitch else if (childValueID.idLowerCase.Equals("usbswitch", StringComparison.CurrentCultureIgnoreCase)) { this.UsbSwitch.Add((usbswitch)Enum.Parse(typeof(usbswitch), childValueID.value, true)); } // parse field Sleep else if (childValueID.idLowerCase.Equals("sleep", StringComparison.CurrentCultureIgnoreCase)) { this.Sleep.Add(UInt32.Parse(childValueID.value)); } else { throw new FormatException(String.Format("Unrecognized child value id \"{0}\"", childID.idOriginalCase)); } } } }
public static void Iterate(this HmdBlockID blockID, AtValueID atValueID, AtBlockID atBlockID) { for (int i = 0; i < blockID.ChildCount; i++) { HmdID id = blockID.GetChild(i); if (id.isBlock) { atBlockID((HmdBlockID)id); } else { atValueID((HmdValueID)id); } } }
public HmdTypeusbdevice(HmdBlockID blockID, HmdProperties hmdProperties) { for (int i = 0; i < blockID.ChildCount; i++) { HmdID childID = blockID.GetChild(i); if (childID.isBlock) { HmdBlockID childBlockID = (HmdBlockID)childID; throw new FormatException(String.Format("Unrecognized child block id \"{0}\"", childID.idOriginalCase)); } else { HmdValueID childValueID = (HmdValueID)childID; // parse field LegacyName if (childValueID.idLowerCase.Equals("legacyname", StringComparison.CurrentCultureIgnoreCase)) { // check that field is not set already if (this.LegacyName != null) { throw new FormatException("Found multiple value id's \"LegacyName\""); } this.LegacyName = (usbdevicelegacyname)Enum.Parse(typeof(usbdevicelegacyname), childValueID.value, true); } // parse field Protocol else if (childValueID.idLowerCase.Equals("protocol", StringComparison.CurrentCultureIgnoreCase)) { // check that field is not set already if (this.Protocol != null) { throw new FormatException("Found multiple value id's \"Protocol\""); } this.Protocol = Byte.Parse(childValueID.value); } // parse field SubClass else if (childValueID.idLowerCase.Equals("subclass", StringComparison.CurrentCultureIgnoreCase)) { // check that field is not set already if (this.SubClass != null) { throw new FormatException("Found multiple value id's \"SubClass\""); } this.SubClass = Byte.Parse(childValueID.value); } // parse field Class else if (childValueID.idLowerCase.Equals("class", StringComparison.CurrentCultureIgnoreCase)) { // check that field is not set already if (this.Class != null) { throw new FormatException("Found multiple value id's \"Class\""); } this.Class = Byte.Parse(childValueID.value); } // parse field Interface else if (childValueID.idLowerCase.Equals("interface", StringComparison.CurrentCultureIgnoreCase)) { // check that field is not set already if (this.Interface != null) { throw new FormatException("Found multiple value id's \"Interface\""); } this.Interface = Byte.Parse(childValueID.value); } // parse field SerialNumber else if (childValueID.idLowerCase.Equals("serialnumber", StringComparison.CurrentCultureIgnoreCase)) { // check that field is not set already if (this.SerialNumber != null) { throw new FormatException("Found multiple value id's \"SerialNumber\""); } this.SerialNumber = childValueID.value; } // parse field Product else if (childValueID.idLowerCase.Equals("product", StringComparison.CurrentCultureIgnoreCase)) { // check that field is not set already if (this.Product != null) { throw new FormatException("Found multiple value id's \"Product\""); } this.Product = childValueID.value; } // parse field Manufacturer else if (childValueID.idLowerCase.Equals("manufacturer", StringComparison.CurrentCultureIgnoreCase)) { // check that field is not set already if (this.Manufacturer != null) { throw new FormatException("Found multiple value id's \"Manufacturer\""); } this.Manufacturer = childValueID.value; } // parse field ProductID else if (childValueID.idLowerCase.Equals("productid", StringComparison.CurrentCultureIgnoreCase)) { // check that field is not set already if (this.ProductID != null) { throw new FormatException("Found multiple value id's \"ProductID\""); } this.ProductID = UInt16.Parse(childValueID.value); } // parse field VendorID else if (childValueID.idLowerCase.Equals("vendorid", StringComparison.CurrentCultureIgnoreCase)) { // check that field is not set already if (this.VendorID != null) { throw new FormatException("Found multiple value id's \"VendorID\""); } this.VendorID = UInt16.Parse(childValueID.value); } // parse field Speed else if (childValueID.idLowerCase.Equals("speed", StringComparison.CurrentCultureIgnoreCase)) { // check that field is not set already if (this.Speed != null) { throw new FormatException("Found multiple value id's \"Speed\""); } this.Speed = (usbdevicespeed)Enum.Parse(typeof(usbdevicespeed), childValueID.value, true); } // parse field PortName else if (childValueID.idLowerCase.Equals("portname", StringComparison.CurrentCultureIgnoreCase)) { // check that field is not set already if (this.PortName != null) { throw new FormatException("Found multiple value id's \"PortName\""); } this.PortName = childValueID.value; } else { throw new FormatException(String.Format("Unrecognized child value id \"{0}\"", childID.idOriginalCase)); } } } }
public void AddChild(HmdID id) { children.Add(id); }