本文整理汇总了C#中XmlQueryType.IsSubtypeOf方法的典型用法代码示例。如果您正苦于以下问题:C# XmlQueryType.IsSubtypeOf方法的具体用法?C# XmlQueryType.IsSubtypeOf怎么用?C# XmlQueryType.IsSubtypeOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlQueryType
的用法示例。
在下文中一共展示了XmlQueryType.IsSubtypeOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddItemToChoice
/// <summary>
/// Adds itemType to a union. Returns false if new item is a subtype of one of the types in the list.
/// </summary>
private static void AddItemToChoice(List<XmlQueryType> accumulator, XmlQueryType itemType) {
Debug.Assert(itemType.IsSingleton, "All types should be prime.");
bool addToList = true;
for (int i = 0; i < accumulator.Count; i++) {
// If new prime is a subtype of existing prime, don't add it to the union
if (itemType.IsSubtypeOf(accumulator[i])) {
return;
}
// If new prime is a subtype of existing prime, then replace the existing prime with new prime
if (accumulator[i].IsSubtypeOf(itemType)) {
if (addToList) {
addToList = false;
accumulator[i] = itemType;
}
else {
accumulator.RemoveAt(i);
i --;
}
}
}
if (addToList) {
accumulator.Add(itemType);
}
}
示例2: IntersectItemTypes
/// <summary>
/// Construct the intersection of two lists of prime XmlQueryTypes.
/// </summary>
private XmlQueryType IntersectItemTypes(XmlQueryType left, XmlQueryType right) {
Debug.Assert(left.Count == 1 && left.IsSingleton, "left should be an item");
Debug.Assert(right.Count == 1 && right.IsSingleton, "right should be an item");
if (left.TypeCode == right.TypeCode && (left.NodeKinds & (XmlNodeKindFlags.Document | XmlNodeKindFlags.Element | XmlNodeKindFlags.Attribute)) != 0) {
if (left.TypeCode == XmlTypeCode.Node) {
return left;
}
// Intersect name tests
XmlQualifiedNameTest nameTest = left.NameTest.Intersect(right.NameTest);
// Intersect types
XmlSchemaType type = XmlSchemaType.IsDerivedFrom(left.SchemaType, right.SchemaType, /* except:*/XmlSchemaDerivationMethod.Empty) ? left.SchemaType :
XmlSchemaType.IsDerivedFrom(right.SchemaType, left.SchemaType, /* except:*/XmlSchemaDerivationMethod.Empty) ? right.SchemaType : null;
bool isNillable = left.IsNillable && right.IsNillable;
if ((object)nameTest == (object)left.NameTest && type == left.SchemaType && isNillable == left.IsNillable) {
// left is a subtype of right return left
return left;
}
else if ((object)nameTest == (object)right.NameTest && type == right.SchemaType && isNillable == right.IsNillable) {
// right is a subtype of left return right
return right;
}
else if (nameTest != null && type != null) {
// create a new type
return ItemType.Create(left.TypeCode, nameTest, type, isNillable);
}
}
else if (left.IsSubtypeOf(right)) {
// left is a subset of right, so left is in the intersection
return left;
}
else if (right.IsSubtypeOf(left)) {
// right is a subset of left, so right is in the intersection
return right;
}
return None;
}