Cardinality of part of XmlQueryType struct is being used because enum doesn't allow members
Esempio n. 1
0
 /// <summary>
 /// Strongly-typed Equals that returns true if this type and "other" type are equivalent.
 /// </summary>
 public bool Equals(XmlQueryCardinality other)
 {
     return(_value == other._value);
 }
Esempio n. 2
0
 /// <summary>
 /// Returns true if this cardinality is guaranteed to be a subset of "other".
 /// </summary>
 private bool IsSubset(XmlQueryCardinality other)
 {
     return((this.value & ~other.value) == 0);
 }
Esempio n. 3
0
 /// <summary>
 /// Returns true if every non-None subset of this cardinality is disjoint with "other" cardinality.
 /// Here is the behavior for None, which is the inverse of the None behavior for IsSubset:
 ///   None op  None = false
 ///   None op ~None = false
 ///  ~None op  None = true
 /// </summary>
 public bool NeverSubset(XmlQueryCardinality other)
 {
     return(_value != 0 && (_value & other._value) == 0);
 }
 /// <summary>
 /// Private constructor.  Create methods should be used to create instances.
 /// </summary>
 private SequenceType(XmlQueryType prime, XmlQueryCardinality card) {
     this.prime = prime;
     this.card = card;
 }
            /// <summary>
            /// Deserialize the object from BinaryReader.
            /// </summary>
            public static XmlQueryType Create(BinaryReader reader) {
                if (reader.ReadBoolean())
                    return TF.NodeSDod;

                XmlQueryType prime = TF.Deserialize(reader);
                XmlQueryCardinality card = new XmlQueryCardinality(reader);
                return Create(prime, card);
            }
 /// <summary>
 /// Compute a sequence of zero to some max cardinality.
 /// </summary>
 /// <param name="t">the type to sequence</param>
 /// <param name="c">the upper bound</param>
 /// <returns>the sequence of t from 0 to c</returns>
 public static XmlQueryType AtMost(XmlQueryType t, XmlQueryCardinality c) {
     return PrimeProduct(t, c.AtMost());
 }
            /// <summary>
            /// Create sequence type from prime and cardinality.
            /// </summary>
            public static XmlQueryType Create(XmlQueryType prime, XmlQueryCardinality card) {
                Debug.Assert(prime != null, "SequenceType can only modify the cardinality of a non-null XmlQueryType.");
                Debug.Assert(prime.IsSingleton, "Prime type must have cardinality one.");

                if (prime.TypeCode == XmlTypeCode.None) {
                    // If cardinality includes zero, then return (None, Zero), else return (None, None).
                    return XmlQueryCardinality.Zero <= card ? Zero : None;
                }

                // Normalize sequences with these cardinalities: None, Zero, One

                if (card == XmlQueryCardinality.None) {
                    return None;
                }
                else if (card == XmlQueryCardinality.Zero) {
                    return Zero;
                }
                else if (card == XmlQueryCardinality.One) {
                    return prime;
                }

                return new SequenceType(prime, card);
            }
        /// <summary>
        /// Compute the product of the prime of "t" with cardinality "c".
        /// </summary>
        /// <param name="t">the member type</param>
        /// <param name="c">the cardinality</param>
        /// <returns>the prime type with the indicated cardinality applied</returns>
        public static XmlQueryType PrimeProduct(XmlQueryType t, XmlQueryCardinality c) {
            // If cardinality stays the same, then this is a no-op
            if (t.Cardinality == c && !t.IsDod)
                return t;

            return SequenceType.Create(t.Prime, c);
        }
 /// <summary>
 /// Compute a sequence with cardinality *= c.
 /// </summary>
 /// <param name="t">the type to sequence</param>
 /// <param name="c">the cardinality multiplier</param>
 /// <returns>the sequence of t with cardinality *= c</returns>
 public static XmlQueryType Product(XmlQueryType t, XmlQueryCardinality c) {
     return PrimeProduct(t, t.Cardinality * c);
 }
 /// <summary>
 /// Create an XmlQueryType from an XmlTypeCode and cardinality.
 /// </summary>
 /// <param name="code">the type code of the item</param>
 /// <param name="card">cardinality</param>
 /// <returns>build-in type type</returns>
 public XmlQueryType Type(XmlTypeCode code, XmlQueryCardinality card) {
     return SequenceType.Create(ItemType.Create(code, false), card);
 }
 /// <summary>
 /// Create an XmlQueryType having an XSD name test, content type, nillable and cardinality.
 /// </summary>
 /// <param name="code">unless code is Document, Element, or Attribute, "contentType" is ignored</param>
 /// <param name="nameTest">name test on the node</param>
 /// <param name="contentType">content type of the node</param>
 /// <param name="isNillable">nillable property</param>
 /// <param name="card">cardinality</param>
 /// <returns>the item type</returns>
 public XmlQueryType Type(XmlTypeCode code, XmlQualifiedNameTest nameTest, XmlSchemaType contentType, bool isNillable, XmlQueryCardinality card) {
     return SequenceType.Create(ItemType.Create(code, nameTest, contentType, isNillable), card);
 }
 /// <summary>
 /// Strongly-typed Equals that returns true if this type and "other" type are equivalent.
 /// </summary>
 public bool Equals(XmlQueryCardinality other) {
     return this.value == other.value;
 }
 /// <summary>
 /// Returns true if every non-None subset of this cardinality is disjoint with "other" cardinality.
 /// Here is the behavior for None, which is the inverse of the None behavior for IsSubset:
 ///   None op  None = false
 ///   None op ~None = false
 ///  ~None op  None = true
 /// </summary>
 public bool NeverSubset(XmlQueryCardinality other) {
     return this.value != 0 && (this.value & other.value) == 0;
 }
 /// <summary>
 /// Returns true if this cardinality is guaranteed to be a subset of "other".
 /// </summary>
 private bool IsSubset(XmlQueryCardinality other) {
     return (this.value & ~other.value) == 0;
 }
Esempio n. 15
0
        private XmlQueryType ParseType(string s)
        {
            if (s != null && s.Length > 0)
            {
                Match m = s_typeInfoRegex.Match(s);
                Debug.Assert(m.Success && m.Groups.Count == 4, "Malformed Type info");

                XmlQueryCardinality qc = new XmlQueryCardinality(m.Groups[1].Value);
                bool strict = bool.Parse(m.Groups[3].Value);

                string[] codes = m.Groups[2].Value.Split('|');
                XmlQueryType[] types = new XmlQueryType[codes.Length];

                for (int i = 0; i < codes.Length; i++)
                    types[i] = XmlQueryTypeFactory.Type((XmlTypeCode)Enum.Parse(typeof(XmlTypeCode), codes[i]), strict);

                return XmlQueryTypeFactory.Product(XmlQueryTypeFactory.Choice(types), qc);
            }
            return null;
        }
Esempio n. 16
0
 /// <summary>
 /// Private constructor.  Create methods should be used to create instances.
 /// </summary>
 private SequenceType(XmlQueryType prime, XmlQueryCardinality card)
 {
     _prime = prime;
     _card = card;
 }