Ejemplo n.º 1
0
 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));
         }
     }
 }
Ejemplo n.º 2
0
 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);
         }
     }
 }
Ejemplo n.º 3
0
        public void SimpleTest()
        {
            String testString = "ABlockID { AValueID: value; AnotherValue: value2; } OtherValue: v; ";

            HmdSingleIDTokenizer tokenizer = new HmdSingleIDTokenizer(new StringReader(testString));
            HmdBlockID           root      = new HmdBlockID(String.Empty, null);

            HmdFileParser.Parse(root, tokenizer, null, null);


            Assert.AreEqual(1, root.ChildCount);
            Assert.IsTrue(root.GetChild(0).isBlock);

            Assert.AreEqual("ABlockID", root.GetChild(0).idOriginalCase);

            HmdBlockID childBlock = root.GetChild(0).CastAsBlockID;

            Assert.AreEqual(2, childBlock.ChildCount);

            Assert.IsFalse(childBlock.GetChild(0).CastAsValueID.isBlock);
            Assert.AreEqual("AValueID", childBlock.GetChild(0).idOriginalCase);
            Assert.AreEqual(" value", childBlock.GetChild(0).CastAsValueID.value);

            Assert.IsFalse(childBlock.GetChild(1).CastAsValueID.isBlock);
            Assert.AreEqual("AnotherValue", childBlock.GetChild(1).idOriginalCase);
            Assert.AreEqual(" value2", childBlock.GetChild(1).CastAsValueID.value);


            root = new HmdBlockID(String.Empty, null);
            tokenizer.Reset();
            HmdFileParser.Parse(root, tokenizer, null, null);

            Assert.AreEqual(1, root.ChildCount);
            Assert.IsFalse(root.GetChild(0).isBlock);

            Assert.AreEqual("OtherValue", root.GetChild(0).idOriginalCase);
            Assert.AreEqual(" v", root.GetChild(0).CastAsValueID.value);
        }
Ejemplo n.º 4
0
 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));
             }
         }
     }
 }
Ejemplo n.º 5
0
 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);
         }
     }
 }
Ejemplo n.º 6
0
 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));
             }
         }
     }
 }