本文整理汇总了C#中System.Xml.Schema.XmlSchemaSimpleType.SetDerivedBy方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaSimpleType.SetDerivedBy方法的具体用法?C# XmlSchemaSimpleType.SetDerivedBy怎么用?C# XmlSchemaSimpleType.SetDerivedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Schema.XmlSchemaSimpleType
的用法示例。
在下文中一共展示了XmlSchemaSimpleType.SetDerivedBy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompileSimpleType
private void CompileSimpleType(XmlSchemaSimpleType simpleType)
{
if (simpleType.IsProcessing)
{
throw new XmlSchemaException("Sch_TypeCircularRef", simpleType);
}
if (simpleType.ElementDecl == null)
{
simpleType.IsProcessing = true;
try
{
if (simpleType.Content is XmlSchemaSimpleTypeList)
{
XmlSchemaDatatype datatype;
XmlSchemaSimpleTypeList content = (XmlSchemaSimpleTypeList) simpleType.Content;
simpleType.SetBaseSchemaType(DatatypeImplementation.AnySimpleType);
if (content.ItemTypeName.IsEmpty)
{
this.CompileSimpleType(content.ItemType);
content.BaseItemType = content.ItemType;
datatype = content.ItemType.Datatype;
}
else
{
XmlSchemaSimpleType type = this.GetSimpleType(content.ItemTypeName);
if (type == null)
{
throw new XmlSchemaException("Sch_UndeclaredSimpleType", content.ItemTypeName.ToString(), simpleType);
}
if ((type.FinalResolved & XmlSchemaDerivationMethod.List) != XmlSchemaDerivationMethod.Empty)
{
base.SendValidationEvent("Sch_BaseFinalList", simpleType);
}
content.BaseItemType = type;
datatype = type.Datatype;
}
simpleType.SetDatatype(datatype.DeriveByList(simpleType));
simpleType.SetDerivedBy(XmlSchemaDerivationMethod.List);
}
else if (simpleType.Content is XmlSchemaSimpleTypeRestriction)
{
XmlSchemaDatatype datatype2;
XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) simpleType.Content;
if (restriction.BaseTypeName.IsEmpty)
{
this.CompileSimpleType(restriction.BaseType);
simpleType.SetBaseSchemaType(restriction.BaseType);
datatype2 = restriction.BaseType.Datatype;
}
else if ((simpleType.Redefined != null) && (restriction.BaseTypeName == simpleType.Redefined.QualifiedName))
{
this.CompileSimpleType((XmlSchemaSimpleType) simpleType.Redefined);
simpleType.SetBaseSchemaType(simpleType.Redefined.BaseXmlSchemaType);
datatype2 = simpleType.Redefined.Datatype;
}
else
{
if (restriction.BaseTypeName.Equals(DatatypeImplementation.QnAnySimpleType))
{
throw new XmlSchemaException("Sch_InvalidSimpleTypeRestriction", restriction.BaseTypeName.ToString(), simpleType);
}
XmlSchemaSimpleType type2 = this.GetSimpleType(restriction.BaseTypeName);
if (type2 == null)
{
throw new XmlSchemaException("Sch_UndeclaredSimpleType", restriction.BaseTypeName.ToString(), simpleType);
}
if ((type2.FinalResolved & XmlSchemaDerivationMethod.Restriction) != XmlSchemaDerivationMethod.Empty)
{
base.SendValidationEvent("Sch_BaseFinalRestriction", simpleType);
}
simpleType.SetBaseSchemaType(type2);
datatype2 = type2.Datatype;
}
simpleType.SetDatatype(datatype2.DeriveByRestriction(restriction.Facets, base.NameTable, simpleType));
simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
}
else
{
XmlSchemaSimpleType[] types = this.CompileBaseMemberTypes(simpleType);
simpleType.SetBaseSchemaType(DatatypeImplementation.AnySimpleType);
simpleType.SetDatatype(XmlSchemaDatatype.DeriveByUnion(types, simpleType));
simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Union);
}
}
catch (XmlSchemaException exception)
{
if (exception.SourceSchemaObject == null)
{
exception.SetSource(simpleType);
}
base.SendValidationEvent(exception);
simpleType.SetDatatype(DatatypeImplementation.AnySimpleType.Datatype);
}
finally
{
SchemaElementDecl decl = new SchemaElementDecl {
ContentValidator = ContentValidator.TextOnly,
SchemaType = simpleType,
Datatype = simpleType.Datatype
};
//.........这里部分代码省略.........
示例2: FinishBuiltinType
/// <summary>
/// Finish constructing built-in types by setting up derivation and list links.
/// </summary>
internal static void FinishBuiltinType(XmlSchemaSimpleType derivedType, XmlSchemaSimpleType baseType) {
Debug.Assert(derivedType != null && baseType != null);
// Create link from the derived type to the base type
derivedType.SetBaseSchemaType(baseType);
derivedType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
if (derivedType.Datatype.Variety == XmlSchemaDatatypeVariety.Atomic) { //Content is restriction
XmlSchemaSimpleTypeRestriction restContent = new XmlSchemaSimpleTypeRestriction();
restContent.BaseTypeName = baseType.QualifiedName;
derivedType.Content = restContent;
}
// Create link from a list type to its member type
if (derivedType.Datatype.Variety == XmlSchemaDatatypeVariety.List) {
XmlSchemaSimpleTypeList listContent = new XmlSchemaSimpleTypeList();
derivedType.SetDerivedBy(XmlSchemaDerivationMethod.List);
switch (derivedType.Datatype.TypeCode) {
case XmlTypeCode.NmToken:
listContent.ItemType = listContent.BaseItemType = enumToTypeCode[(int) XmlTypeCode.NmToken];
break;
case XmlTypeCode.Entity:
listContent.ItemType = listContent.BaseItemType = enumToTypeCode[(int) XmlTypeCode.Entity];
break;
case XmlTypeCode.Idref:
listContent.ItemType = listContent.BaseItemType = enumToTypeCode[(int) XmlTypeCode.Idref];
break;
}
derivedType.Content = listContent;
}
}
示例3: CompileSimpleType
private void CompileSimpleType(XmlSchemaSimpleType simpleType) {
if (simpleType.Validating) {
throw new XmlSchemaException(Res.Sch_TypeCircularRef, simpleType);
}
if (simpleType.ElementDecl != null) { // already compiled
return;
}
simpleType.Validating = true;
try {
if (simpleType.Content is XmlSchemaSimpleTypeList) {
XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)simpleType.Content;
XmlSchemaDatatype datatype;
if (list.ItemTypeName.IsEmpty) {
CompileSimpleType(list.ItemType);
simpleType.SetBaseSchemaType(list.ItemType);
datatype = list.ItemType.Datatype;
}
else {
datatype = GetDatatype(list.ItemTypeName);
if (datatype != null) {
simpleType.SetBaseSchemaType(datatype);
}
else {
XmlSchemaSimpleType type = GetSimpleType(list.ItemTypeName);
if (type != null) {
if ((type.FinalResolved & XmlSchemaDerivationMethod.List) != 0) {
SendValidationEvent(Res.Sch_BaseFinalList, simpleType);
}
simpleType.SetBaseSchemaType(type);
datatype = type.Datatype;
}
else {
throw new XmlSchemaException(Res.Sch_UndeclaredSimpleType, list.ItemTypeName.ToString(), simpleType);
}
}
}
simpleType.SetDatatype(datatype.DeriveByList());
simpleType.SetDerivedBy(XmlSchemaDerivationMethod.List);
}
else if (simpleType.Content is XmlSchemaSimpleTypeRestriction) {
XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)simpleType.Content;
XmlSchemaDatatype datatype;
if (restriction.BaseTypeName.IsEmpty) {
CompileSimpleType(restriction.BaseType);
simpleType.SetBaseSchemaType(restriction.BaseType);
datatype = restriction.BaseType.Datatype;
}
else if (simpleType.Redefined != null && restriction.BaseTypeName == simpleType.Redefined.QualifiedName) {
CompileSimpleType((XmlSchemaSimpleType)simpleType.Redefined);
simpleType.SetBaseSchemaType(simpleType.Redefined.BaseSchemaType);
datatype = simpleType.Redefined.Datatype;
}
else {
datatype = GetDatatype(restriction.BaseTypeName);
if (datatype != null) {
simpleType.SetBaseSchemaType(datatype);
}
else {
XmlSchemaSimpleType type = GetSimpleType(restriction.BaseTypeName);
if (type != null) {
if ((type.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) {
SendValidationEvent(Res.Sch_BaseFinalRestriction, simpleType);
}
simpleType.SetBaseSchemaType(type);
datatype = type.Datatype;
}
else {
throw new XmlSchemaException(Res.Sch_UndeclaredSimpleType, restriction.BaseTypeName.ToString(), simpleType);
}
}
}
simpleType.SetDatatype(datatype.DeriveByRestriction(restriction.Facets, this.nameTable));
simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
}
else { //simpleType.Content is XmlSchemaSimpleTypeUnion
XmlSchemaSimpleTypeUnion union1 = (XmlSchemaSimpleTypeUnion)simpleType.Content;
int baseTypeCount = union1.BaseTypes.Count;
if (union1.MemberTypes != null) {
baseTypeCount += union1.MemberTypes.Length;
}
object[] baseTypes = new object[baseTypeCount];
XmlSchemaDatatype[] baseDatatypes = new XmlSchemaDatatype[baseTypeCount];
int idx = 0;
if (union1.MemberTypes != null) {
foreach (XmlQualifiedName qname in union1.MemberTypes) {
XmlSchemaDatatype datatype = GetDatatype(qname);
if (datatype != null) {
baseTypes[idx] = datatype;
baseDatatypes[idx ++] = datatype;
}
else {
XmlSchemaSimpleType type = GetSimpleType(qname);
if (type != null) {
if ((type.FinalResolved & XmlSchemaDerivationMethod.Union) != 0) {
SendValidationEvent(Res.Sch_BaseFinalUnion, simpleType);
}
baseTypes[idx] = type;
baseDatatypes[idx ++] = type.Datatype;
}
else {
//.........这里部分代码省略.........
示例4: CompileSimpleType
private void CompileSimpleType(XmlSchemaSimpleType simpleType) {
if (simpleType.IsProcessing) {
throw new XmlSchemaException(Res.Sch_TypeCircularRef, simpleType);
}
if (simpleType.ElementDecl != null) { // already compiled
return;
}
simpleType.IsProcessing = true;
try {
if (simpleType.Content is XmlSchemaSimpleTypeList) {
XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)simpleType.Content;
XmlSchemaDatatype datatype;
simpleType.SetBaseSchemaType(DatatypeImplementation.AnySimpleType);
if (list.ItemTypeName.IsEmpty) {
CompileSimpleType(list.ItemType);
list.BaseItemType = list.ItemType;
datatype = list.ItemType.Datatype;
}
else {
XmlSchemaSimpleType type = GetSimpleType(list.ItemTypeName);
if (type != null) {
if ((type.FinalResolved & XmlSchemaDerivationMethod.List) != 0) {
SendValidationEvent(Res.Sch_BaseFinalList, simpleType);
}
list.BaseItemType = type;
datatype = type.Datatype;
}
else {
throw new XmlSchemaException(Res.Sch_UndeclaredSimpleType, list.ItemTypeName.ToString(), list);
}
}
simpleType.SetDatatype(datatype.DeriveByList(simpleType));
simpleType.SetDerivedBy(XmlSchemaDerivationMethod.List);
}
else if (simpleType.Content is XmlSchemaSimpleTypeRestriction) {
XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)simpleType.Content;
XmlSchemaDatatype datatype;
if (restriction.BaseTypeName.IsEmpty) {
CompileSimpleType(restriction.BaseType);
simpleType.SetBaseSchemaType(restriction.BaseType);
datatype = restriction.BaseType.Datatype;
}
else if (simpleType.Redefined != null && restriction.BaseTypeName == simpleType.Redefined.QualifiedName) {
CompileSimpleType((XmlSchemaSimpleType)simpleType.Redefined);
simpleType.SetBaseSchemaType(simpleType.Redefined.BaseXmlSchemaType);
datatype = simpleType.Redefined.Datatype;
}
else {
if (restriction.BaseTypeName.Equals(DatatypeImplementation.QnAnySimpleType)) {
XmlSchema parentSchema = Preprocessor.GetParentSchema(simpleType);
if (parentSchema.TargetNamespace != XmlSchema.Namespace) { //If it is not SForS, then error
throw new XmlSchemaException(Res.Sch_InvalidSimpleTypeRestriction, restriction.BaseTypeName.ToString(), simpleType);
}
}
XmlSchemaSimpleType type = GetSimpleType(restriction.BaseTypeName);
if (type != null) {
if ((type.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) {
SendValidationEvent(Res.Sch_BaseFinalRestriction, simpleType);
}
simpleType.SetBaseSchemaType(type);
datatype = type.Datatype;
}
else {
throw new XmlSchemaException(Res.Sch_UndeclaredSimpleType, restriction.BaseTypeName.ToString(), restriction);
}
}
simpleType.SetDatatype(datatype.DeriveByRestriction(restriction.Facets, NameTable, simpleType));
simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
}
else { //simpleType.Content is XmlSchemaSimpleTypeUnion
XmlSchemaSimpleType[] baseTypes = CompileBaseMemberTypes(simpleType);
simpleType.SetBaseSchemaType(DatatypeImplementation.AnySimpleType);
simpleType.SetDatatype(XmlSchemaDatatype.DeriveByUnion(baseTypes, simpleType));
simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Union);
}
}
catch (XmlSchemaException e) {
if (e.SourceSchemaObject == null) {
e.SetSource(simpleType);
}
SendValidationEvent(e);
simpleType.SetDatatype(DatatypeImplementation.AnySimpleType.Datatype);
}
finally {
SchemaElementDecl decl = new SchemaElementDecl();
decl.ContentValidator = ContentValidator.TextOnly;
decl.SchemaType = simpleType;
decl.Datatype = simpleType.Datatype;
simpleType.ElementDecl = decl;
simpleType.IsProcessing = false;
}
}
示例5: FinishBuiltinType
internal static void FinishBuiltinType(XmlSchemaSimpleType derivedType, XmlSchemaSimpleType baseType)
{
derivedType.SetBaseSchemaType(baseType);
derivedType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
if (derivedType.Datatype.Variety == XmlSchemaDatatypeVariety.Atomic)
{
XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction {
BaseTypeName = baseType.QualifiedName
};
derivedType.Content = restriction;
}
if (derivedType.Datatype.Variety == XmlSchemaDatatypeVariety.List)
{
XmlSchemaSimpleTypeList list = new XmlSchemaSimpleTypeList();
derivedType.SetDerivedBy(XmlSchemaDerivationMethod.List);
switch (derivedType.Datatype.TypeCode)
{
case XmlTypeCode.Idref:
list.ItemType = list.BaseItemType = enumToTypeCode[0x26];
break;
case XmlTypeCode.Entity:
list.ItemType = list.BaseItemType = enumToTypeCode[0x27];
break;
case XmlTypeCode.NmToken:
list.ItemType = list.BaseItemType = enumToTypeCode[0x22];
break;
}
derivedType.Content = list;
}
}