/// <summary> /// Sets the data for a specified box type using values from /// a <see cref="ByteVectorCollection" /> object. /// </summary> /// <param name="type"> /// A <see cref="ByteVector" /> object containing the type to /// add to the new instance. /// </param> /// <param name="data"> /// A <see cref="ByteVectorCollection" /> object containing /// data to add for the specified type. /// </param> /// <param name="flags"> /// A <see cref="uint" /> value containing flags to use for /// the added boxes. /// </param> public void SetData(ByteVector type, ByteVectorCollection data, uint flags) { if (data == null || data.Count == 0) { ClearData(type); return; } AppleDataBox [] boxes = new AppleDataBox [data.Count]; for (int i = 0; i < data.Count; i++) { boxes [i] = new AppleDataBox(data [i], flags); } SetData(type, boxes); }
/// <summary> /// Gets all custom data boxes that match the specified mean /// and name pair. /// </summary> /// <param name="mean"> /// A <see cref="string" /> object containing the "mean" to /// match. /// </param> /// <param name="name"> /// A <see cref="string" /> object containing the name to /// match. /// </param> /// <returns> /// A <see cref="T:System.Collections.Generic.IEnumerable`1" /> object enumerating the /// matching boxes. /// </returns> public IEnumerable <AppleDataBox> DataBoxes(string mean, string name) { // These children will have a box type of "----" foreach (Box box in ilst_box.Children) { if (box.BoxType != BoxType.DASH) { continue; } // Get the mean and name boxes, make sure // they're legit, and make sure that they match // what we want. Then loop through and add all // the data box children to our output. AppleAdditionalInfoBox mean_box = (AppleAdditionalInfoBox) box.GetChild(BoxType.Mean); AppleAdditionalInfoBox name_box = (AppleAdditionalInfoBox) box.GetChild(BoxType.Name); if (mean_box == null || name_box == null || mean_box.Text != mean || name_box.Text != name) { continue; } foreach (Box data_box in box.Children) { AppleDataBox adb = data_box as AppleDataBox; if (adb != null) { yield return(adb); } } } }