/// <summary>
        /// Serialize XmlQueryType to BinaryWriter.
        /// </summary>
        public static void Serialize(BinaryWriter writer, XmlQueryType type) {
            sbyte subtypeId;

            if (type.GetType() == typeof(ItemType))
                subtypeId = 0;
            else if (type.GetType() == typeof(ChoiceType))
                subtypeId = 1;
            else if (type.GetType() == typeof(SequenceType))
                subtypeId = 2;
            else {
                Debug.Fail("Don't know how to serialize " + type.GetType().ToString());
                subtypeId = -1;
            }

            writer.Write(subtypeId);
            type.GetObjectData(writer);
        }
 public static void CheckSerializability(XmlQueryType type) {
     type.GetObjectData(new BinaryWriter(Stream.Null));
 }