本文整理汇总了C#中System.Xml.Schema.XmlSchemaComplexContent类的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaComplexContent类的具体用法?C# XmlSchemaComplexContent怎么用?C# XmlSchemaComplexContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlSchemaComplexContent类属于System.Xml.Schema命名空间,在下文中一共展示了XmlSchemaComplexContent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateProtoComplexType
XObject[] CreateProtoComplexType(XmlSchemaComplexType complexType) {
if (complexType.ContentModel != null) {
if ((complexType.ContentModel as XmlSchemaSimpleContent) != null) {
return CreateProtoSimpleContent((complexType.ContentModel as XmlSchemaSimpleContent), complexType.BaseXmlSchemaType).ToArray();
} else if ((complexType.ContentModel as XmlSchemaComplexContent) != null) {
return CreateProtoComplexContent((complexType.ContentModel as XmlSchemaComplexContent), complexType.BaseXmlSchemaType).ToArray();
} else {
throw new Exception("not implemented");
}
} else {
var complexContentExt = new XmlSchemaComplexContentExtension();
if (complexType.BaseXmlSchemaType != null) {
complexContentExt.BaseTypeName = complexType.BaseXmlSchemaType.QualifiedName;
} else {
complexContentExt.BaseTypeName = null;
}
if (complexType.Attributes != null) {
foreach (var i in complexType.Attributes) {
complexContentExt.Attributes.Add(i);
}
}
complexContentExt.Particle = complexType.Particle;
var complexContent = new XmlSchemaComplexContent();
complexContent.Content = complexContentExt;
return CreateProtoComplexContent(complexContent, complexType.BaseXmlSchemaType).ToArray();
}
}
示例2: WriteComplexSchemaType
/// <summary>
/// Handle derivation by extension.
/// If type is null, it'll create a new complexType
/// with an XmlAny node in its sequence child node.
/// </summary>
public XmlSchemaType WriteComplexSchemaType (Type type)
{
//
// Recursively generate schema for all parent types
//
if (type != null && type.BaseType == typeof (object))
return WriteSchemaType (type);
XmlSchemaComplexType complexType = new XmlSchemaComplexType ();
XmlSchemaSequence sequence;
XmlSchemaComplexContentExtension extension = new XmlSchemaComplexContentExtension ();
XmlSchemaComplexContent content = new XmlSchemaComplexContent ();
complexType.ContentModel = content;
content.Content = extension;
XmlSchemaType baseSchemaType = WriteSchemaType (type.BaseType);
complexType.Name = type.Name;
FieldInfo [] fields = type.GetFields (flags);
PropertyInfo [] properties = type.GetProperties (flags);
try {
sequence = PopulateSequence (fields, properties);
if (attributes != null) {
foreach (object o in attributes) {
MemberInfo member = (MemberInfo) o;
Type attribute_type = (Type) attributes [o];
complexType.Attributes.Add (WriteSchemaAttribute (member, attribute_type));
}
}
} catch (ArgumentException e) {
throw new ArgumentException (String.Format ("There is an error in '{0}'\n\t{1}", type.Name, e.Message));
}
extension.BaseTypeName = new XmlQualifiedName (baseSchemaType.Name);
extension.Particle = sequence;
generatedSchemaTypes.Add (type.FullName, complexType);
return complexType;
}
示例3: CompileComplexContentRestriction
private void CompileComplexContentRestriction(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentRestriction complexRestriction)
{
XmlSchemaComplexType redefined = null;
if ((complexType.Redefined != null) && (complexRestriction.BaseTypeName == complexType.Redefined.QualifiedName))
{
redefined = (XmlSchemaComplexType) complexType.Redefined;
this.CompileComplexType(redefined);
}
else
{
redefined = this.GetComplexType(complexRestriction.BaseTypeName);
if (redefined == null)
{
base.SendValidationEvent("Sch_UndefBaseRestriction", complexRestriction.BaseTypeName.ToString(), complexRestriction);
return;
}
}
if (((redefined != null) && (redefined.ElementDecl != null)) && (redefined.ContentType == XmlSchemaContentType.TextOnly))
{
base.SendValidationEvent("Sch_NotComplexContent", complexType);
}
else
{
complexType.SetBaseSchemaType(redefined);
if ((redefined.FinalResolved & XmlSchemaDerivationMethod.Restriction) != XmlSchemaDerivationMethod.Empty)
{
base.SendValidationEvent("Sch_BaseFinalRestriction", complexType);
}
this.CompileLocalAttributes(redefined, complexType, complexRestriction.Attributes, complexRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction);
complexType.SetContentTypeParticle(this.CompileContentTypeParticle(complexRestriction.Particle, true));
complexType.SetContentType(this.GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle));
if (complexType.ContentType == XmlSchemaContentType.Empty)
{
SchemaElementDecl elementDecl = redefined.ElementDecl;
if ((redefined.ElementDecl != null) && !redefined.ElementDecl.ContentValidator.IsEmptiable)
{
base.SendValidationEvent("Sch_InvalidContentRestriction", complexType);
}
}
complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
}
}
示例4: Write41_XmlSchemaComplexContent
void Write41_XmlSchemaComplexContent(XmlSchemaComplexContent o) {
if ((object)o == null) return;
WriteStartElement("complexContent");
WriteAttribute(@"id", @"", ((System.String)[email protected]));
WriteAttribute(@"mixed", @"", XmlConvert.ToString((System.Boolean)((System.Boolean)[email protected])));
WriteAttributes((XmlAttribute[])[email protected], o);
Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)[email protected]);
if ([email protected] is XmlSchemaComplexContentRestriction) {
Write56_XmlSchemaComplexContentRestriction((XmlSchemaComplexContentRestriction)[email protected]);
}
else if ([email protected] is XmlSchemaComplexContentExtension) {
Write42_XmlSchemaComplexContentExtension((XmlSchemaComplexContentExtension)[email protected]);
}
WriteEndElement();
}
示例5: SetContainer
private void SetContainer(State state, object container) {
switch (state) {
case State.Root:
break;
case State.Schema:
break;
case State.Annotation:
this.annotation = (XmlSchemaAnnotation)container;
break;
case State.Include:
this.include = (XmlSchemaInclude)container;
break;
case State.Import:
this.import = (XmlSchemaImport)container;
break;
case State.Element:
this.element = (XmlSchemaElement)container;
break;
case State.Attribute:
this.attribute = (XmlSchemaAttribute)container;
break;
case State.AttributeGroup:
this.attributeGroup = (XmlSchemaAttributeGroup)container;
break;
case State.AttributeGroupRef:
this.attributeGroupRef = (XmlSchemaAttributeGroupRef)container;
break;
case State.AnyAttribute:
this.anyAttribute = (XmlSchemaAnyAttribute)container;
break;
case State.Group:
this.group = (XmlSchemaGroup)container;
break;
case State.GroupRef:
this.groupRef = (XmlSchemaGroupRef)container;
break;
case State.All:
this.all = (XmlSchemaAll)container;
break;
case State.Choice:
this.choice = (XmlSchemaChoice)container;
break;
case State.Sequence:
this.sequence = (XmlSchemaSequence)container;
break;
case State.Any:
this.anyElement = (XmlSchemaAny)container;
break;
case State.Notation:
this.notation = (XmlSchemaNotation)container;
break;
case State.SimpleType:
this.simpleType = (XmlSchemaSimpleType)container;
break;
case State.ComplexType:
this.complexType = (XmlSchemaComplexType)container;
break;
case State.ComplexContent:
this.complexContent = (XmlSchemaComplexContent)container;
break;
case State.ComplexContentExtension:
this.complexContentExtension = (XmlSchemaComplexContentExtension)container;
break;
case State.ComplexContentRestriction:
this.complexContentRestriction = (XmlSchemaComplexContentRestriction)container;
break;
case State.SimpleContent:
this.simpleContent = (XmlSchemaSimpleContent)container;
break;
case State.SimpleContentExtension:
this.simpleContentExtension = (XmlSchemaSimpleContentExtension)container;
break;
case State.SimpleContentRestriction:
this.simpleContentRestriction = (XmlSchemaSimpleContentRestriction)container;
break;
case State.SimpleTypeUnion:
this.simpleTypeUnion = (XmlSchemaSimpleTypeUnion)container;
break;
case State.SimpleTypeList:
this.simpleTypeList = (XmlSchemaSimpleTypeList)container;
break;
case State.SimpleTypeRestriction:
this.simpleTypeRestriction = (XmlSchemaSimpleTypeRestriction)container;
break;
case State.Unique:
case State.Key:
case State.KeyRef:
this.identityConstraint = (XmlSchemaIdentityConstraint)container;
break;
case State.Selector:
case State.Field:
this.xpath = (XmlSchemaXPath)container;
break;
case State.MinExclusive:
case State.MinInclusive:
case State.MaxExclusive:
case State.MaxInclusive:
case State.TotalDigits:
case State.FractionDigits:
case State.Length:
//.........这里部分代码省略.........
示例6: CompileComplexContentExtension
private void CompileComplexContentExtension(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentExtension complexExtension) {
XmlSchemaComplexType baseType = null;
if (complexType.Redefined != null && complexExtension.BaseTypeName == complexType.Redefined.QualifiedName) {
baseType = (XmlSchemaComplexType)complexType.Redefined;
CompileComplexType(baseType);
}
else {
baseType = GetComplexType(complexExtension.BaseTypeName);
if (baseType == null) {
SendValidationEvent(Res.Sch_UndefBaseExtension, complexExtension.BaseTypeName.ToString(), complexExtension);
return;
}
}
if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Extension) != 0) {
SendValidationEvent(Res.Sch_BaseFinalExtension, complexType);
}
CompileLocalAttributes(baseType, complexType, complexExtension.Attributes, complexExtension.AnyAttribute, XmlSchemaDerivationMethod.Extension);
XmlSchemaParticle baseParticle = baseType.ContentTypeParticle;
XmlSchemaParticle extendedParticle = CannonicalizeParticle(complexExtension.Particle, true);
if (baseParticle != XmlSchemaParticle.Empty) {
if (extendedParticle != XmlSchemaParticle.Empty) {
XmlSchemaSequence compiledParticle = new XmlSchemaSequence();
compiledParticle.Items.Add(baseParticle);
compiledParticle.Items.Add(extendedParticle);
complexType.SetContentTypeParticle(CompileContentTypeParticle(compiledParticle));
}
else {
complexType.SetContentTypeParticle(baseParticle);
}
}
else {
complexType.SetContentTypeParticle(extendedParticle);
}
XmlSchemaContentType contentType = GetSchemaContentType(complexType, complexContent, extendedParticle);
if (contentType == XmlSchemaContentType.Empty) { //Derived content type is empty, Get ContentType from base
contentType = baseType.ContentType;
// In case of a simple base type (content type is TextOnly) the derived type
// will be the same as the base type. So set the same content type and then also
// set the same data type.
if (contentType == XmlSchemaContentType.TextOnly) {
complexType.SetDatatype(baseType.Datatype);
}
}
complexType.SetContentType(contentType);
if (baseType.ContentType != XmlSchemaContentType.Empty && complexType.ContentType != baseType.ContentType) { //If base is empty, do not check
SendValidationEvent(Res.Sch_DifContentType, complexType);
return;
}
complexType.SetBaseSchemaType(baseType);
complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension);
}
示例7: GetChildElementCompletion
XmlCompletionItemCollection GetChildElementCompletion(XmlSchemaComplexContent complexContent, string prefix)
{
XmlSchemaComplexContentExtension extension = complexContent.Content as XmlSchemaComplexContentExtension;
if (extension != null) {
return GetChildElementCompletion(extension, prefix);
} else {
XmlSchemaComplexContentRestriction restriction = complexContent.Content as XmlSchemaComplexContentRestriction;
if (restriction != null) {
return GetChildElementCompletion(restriction, prefix);
}
}
return new XmlCompletionItemCollection();
}
示例8: FindAttribute
XmlSchemaAttribute FindAttribute (XmlSchemaComplexContent complexContent, string name)
{
var extension = complexContent.Content as XmlSchemaComplexContentExtension;
if (extension != null)
return FindAttribute (extension, name);
var restriction = complexContent.Content as XmlSchemaComplexContentRestriction;
if (restriction != null)
return FindAttribute (restriction, name);
return null;
}
示例9: ExportArraySchema
XmlQualifiedName ExportArraySchema (XmlTypeMapping map, string defaultNamespace)
{
ListMap lmap = (ListMap) map.ObjectMap;
if (encodedFormat)
{
string name, ns, schemaNs;
lmap.GetArrayType (-1, out name, out ns);
if (ns == XmlSchema.Namespace) schemaNs = defaultNamespace;
else schemaNs = ns;
if (IsMapExported (map)) return new XmlQualifiedName (lmap.GetSchemaArrayName (), schemaNs);
SetMapExported (map);
XmlSchema schema = GetSchema (schemaNs);
XmlSchemaComplexType stype = new XmlSchemaComplexType ();
stype.Name = lmap.GetSchemaArrayName ();
schema.Items.Add (stype);
XmlSchemaComplexContent content = new XmlSchemaComplexContent();
content.IsMixed = false;
stype.ContentModel = content;
XmlSchemaComplexContentRestriction rest = new XmlSchemaComplexContentRestriction ();
content.Content = rest;
rest.BaseTypeName = new XmlQualifiedName ("Array", XmlSerializer.EncodingNamespace);
XmlSchemaAttribute at = new XmlSchemaAttribute ();
rest.Attributes.Add (at);
at.RefName = new XmlQualifiedName ("arrayType", XmlSerializer.EncodingNamespace);
XmlAttribute arrayType = Document.CreateAttribute ("arrayType", XmlSerializer.WsdlNamespace);
arrayType.Value = ns + (ns != "" ? ":" : "") + name;
at.UnhandledAttributes = new XmlAttribute [] { arrayType };
ImportNamespace (schema, XmlSerializer.WsdlNamespace);
XmlTypeMapElementInfo einfo = (XmlTypeMapElementInfo) lmap.ItemInfo[0];
if (einfo.MappedType != null)
{
switch (einfo.TypeData.SchemaType)
{
case SchemaTypes.Enum:
ExportEnumSchema (einfo.MappedType);
break;
case SchemaTypes.Array:
ExportArraySchema (einfo.MappedType, schemaNs);
break;
case SchemaTypes.Class:
ExportClassSchema (einfo.MappedType);
break;
}
}
return new XmlQualifiedName (lmap.GetSchemaArrayName (), schemaNs);
}
else
{
if (IsMapExported (map)) return new XmlQualifiedName (map.XmlType, map.XmlTypeNamespace);
SetMapExported (map);
XmlSchema schema = GetSchema (map.XmlTypeNamespace);
XmlSchemaComplexType stype = new XmlSchemaComplexType ();
stype.Name = map.ElementName;
schema.Items.Add (stype);
XmlSchemaParticle spart = GetSchemaArrayElement (schema, lmap.ItemInfo);
if (spart is XmlSchemaChoice)
stype.Particle = spart;
else
{
XmlSchemaSequence seq = new XmlSchemaSequence ();
seq.Items.Add (spart);
stype.Particle = seq;
}
return new XmlQualifiedName (map.XmlType, map.XmlTypeNamespace);
}
}
示例10: ExportClassSchema
void ExportClassSchema (XmlTypeMapping map)
{
if (IsMapExported (map)) return;
SetMapExported (map);
if (map.TypeData.Type == typeof(object))
{
foreach (XmlTypeMapping dmap in map.DerivedTypes)
if (dmap.TypeData.SchemaType == SchemaTypes.Class) ExportClassSchema (dmap);
return;
}
XmlSchema schema = GetSchema (map.XmlTypeNamespace);
XmlSchemaComplexType stype = new XmlSchemaComplexType ();
stype.Name = map.XmlType;
schema.Items.Add (stype);
ClassMap cmap = (ClassMap)map.ObjectMap;
if (cmap.HasSimpleContent)
{
XmlSchemaSimpleContent simple = new XmlSchemaSimpleContent ();
stype.ContentModel = simple;
XmlSchemaSimpleContentExtension ext = new XmlSchemaSimpleContentExtension ();
simple.Content = ext;
XmlSchemaSequence particle;
XmlSchemaAnyAttribute anyAttribute;
ExportMembersMapSchema (schema, cmap, map.BaseMap, ext.Attributes, out particle, out anyAttribute);
ext.AnyAttribute = anyAttribute;
if (map.BaseMap == null)
ext.BaseTypeName = cmap.SimpleContentBaseType;
else {
ext.BaseTypeName = new XmlQualifiedName (map.BaseMap.XmlType, map.BaseMap.XmlTypeNamespace);
ImportNamespace (schema, map.BaseMap.XmlTypeNamespace);
ExportClassSchema (map.BaseMap);
}
}
else if (map.BaseMap != null && map.BaseMap.IncludeInSchema)
{
XmlSchemaComplexContent cstype = new XmlSchemaComplexContent ();
XmlSchemaComplexContentExtension ext = new XmlSchemaComplexContentExtension ();
ext.BaseTypeName = new XmlQualifiedName (map.BaseMap.XmlType, map.BaseMap.XmlTypeNamespace);
cstype.Content = ext;
stype.ContentModel = cstype;
XmlSchemaSequence particle;
XmlSchemaAnyAttribute anyAttribute;
ExportMembersMapSchema (schema, cmap, map.BaseMap, ext.Attributes, out particle, out anyAttribute);
ext.Particle = particle;
ext.AnyAttribute = anyAttribute;
stype.IsMixed = HasMixedContent (map);
cstype.IsMixed = BaseHasMixedContent (map);
ImportNamespace (schema, map.BaseMap.XmlTypeNamespace);
ExportClassSchema (map.BaseMap);
}
else
{
XmlSchemaSequence particle;
XmlSchemaAnyAttribute anyAttribute;
ExportMembersMapSchema (schema, cmap, map.BaseMap, stype.Attributes, out particle, out anyAttribute);
stype.Particle = particle;
stype.AnyAttribute = anyAttribute;
stype.IsMixed = cmap.XmlTextCollector != null;
}
foreach (XmlTypeMapping dmap in map.DerivedTypes)
if (dmap.TypeData.SchemaType == SchemaTypes.Class) ExportClassSchema (dmap);
}
示例11: CreateSchemaComplexType
/// <summary>
/// Creates the an xml schema for a complex type. This method automatically takes care of
/// any base classes that must be added.
/// <para />
/// This method already adds the <see cref="XmlSchemaComplexType" /> to the <see cref="XmlSchemaSet" />.
/// </summary>
/// <param name="type">The type to create the complex schema for.</param>
/// <param name="schema">The schema.</param>
/// <param name="schemaSet">The schema set.</param>
/// <param name="serializationManager">The serialization manager.</param>
/// <param name="generateFlatSchema">A value indicating whether the schema should be generated as flat schema.</param>
/// <returns>The complex schema for the specified type.</returns>
private static XmlSchemaComplexType CreateSchemaComplexType(Type type, XmlSchema schema, XmlSchemaSet schemaSet, ISerializationManager serializationManager, bool generateFlatSchema)
{
// Determine name, which is complex in generic types
string typeName = GetTypeNameForSchema(type);
// First, add the type, otherwise we might get into a stackoverflow when using generic base types
// <xs:complexType>
var modelBaseType = new XmlSchemaComplexType();
modelBaseType.Name = typeName;
modelBaseType.IsMixed = false;
schema.Items.Add(modelBaseType);
var propertiesSequence = GetPropertiesSequence(type, schema, schemaSet, serializationManager);
// If flat, don't generate base classes, just the type itself
if (generateFlatSchema)
{
modelBaseType.Particle = propertiesSequence;
return modelBaseType;
}
if (type.IsGenericType)
{
var genericComplexType = new XmlSchemaComplexType();
genericComplexType.Name = typeName;
// <xs:annotation>
var annotation = new XmlSchemaAnnotation();
// <xs:appinfo>
var appInfo = new XmlSchemaAppInfo();
//<GenericType xmlns="http://schemas.microsoft.com/2003/10/Serialization/" Name="DataContractBaseOf{0}{#}" Namespace="http://schemas.datacontract.org/2004/07/STC">
// <GenericParameter Name="ProfileDateRange2" Namespace="http://schemas.datacontract.org/2004/07/STC.Meter.ProfileData"/>
//</GenericType>
var genericTypeElement = new XElement("GenericType");
genericTypeElement.Add(new XAttribute("Name", string.Format("{0}Of{{0}}{{#}}", typeName)));
genericTypeElement.Add(new XAttribute("Namespace", GetTypeNamespaceForSchema(type)));
foreach (var genericArgument in type.GetGenericArgumentsEx())
{
var genericArgumentQualifiedName = AddTypeToSchemaSet(genericArgument, schemaSet, serializationManager);
var genericArgumentElement = new XElement("GenericParameter");
genericArgumentElement.Add(new XAttribute("Name", genericArgumentQualifiedName.Name));
genericArgumentElement.Add(new XAttribute("Namespace", genericArgumentQualifiedName.Namespace));
genericTypeElement.Add(genericArgumentElement);
}
var conversionDoc = new XmlDocument();
appInfo.Markup = new XmlNode[] { conversionDoc.CreateTextNode(genericTypeElement.ToString()) };
annotation.Items.Add(appInfo);
}
var baseTypeQualifiedName = AddTypeToSchemaSet(type.BaseType, schemaSet, serializationManager);
if (baseTypeQualifiedName != null)
{
// <xs:extensions base="address">
var complexContentExtension = new XmlSchemaComplexContentExtension();
complexContentExtension.BaseTypeName = baseTypeQualifiedName;
complexContentExtension.Particle = propertiesSequence;
// <xs:complexContent>
var complexContent = new XmlSchemaComplexContent();
complexContent.Content = complexContentExtension;
modelBaseType.ContentModel = complexContent;
}
return modelBaseType;
}
示例12: CompileComplexContentRestriction
private void CompileComplexContentRestriction(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentRestriction complexRestriction)
{
XmlSchemaComplexType redefined = null;
if ((complexType.Redefined != null) && (complexRestriction.BaseTypeName == complexType.Redefined.QualifiedName))
{
redefined = (XmlSchemaComplexType) complexType.Redefined;
this.CompileComplexType(redefined);
}
else
{
redefined = this.GetComplexType(complexRestriction.BaseTypeName);
if (redefined == null)
{
base.SendValidationEvent("Sch_UndefBaseRestriction", complexRestriction.BaseTypeName.ToString(), complexRestriction);
return;
}
}
complexType.SetBaseSchemaType(redefined);
if ((redefined.FinalResolved & XmlSchemaDerivationMethod.Restriction) != XmlSchemaDerivationMethod.Empty)
{
base.SendValidationEvent("Sch_BaseFinalRestriction", complexType);
}
this.CompileLocalAttributes(redefined, complexType, complexRestriction.Attributes, complexRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction);
complexType.SetContentTypeParticle(this.CompileContentTypeParticle(complexRestriction.Particle));
XmlSchemaContentType type2 = this.GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle);
complexType.SetContentType(type2);
switch (type2)
{
case XmlSchemaContentType.Empty:
if ((redefined.ElementDecl != null) && !redefined.ElementDecl.ContentValidator.IsEmptiable)
{
base.SendValidationEvent("Sch_InvalidContentRestrictionDetailed", Res.GetString("Sch_InvalidBaseToEmpty"), complexType);
}
break;
case XmlSchemaContentType.Mixed:
if (redefined.ContentType != XmlSchemaContentType.Mixed)
{
base.SendValidationEvent("Sch_InvalidContentRestrictionDetailed", Res.GetString("Sch_InvalidBaseToMixed"), complexType);
}
break;
}
complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
}
示例13: BuildComplexContent
private void BuildComplexContent(XmlSchemaComplexContent complexContent, CodeTypeDeclaration codeType)
{
// If this is an extension type
if (complexContent.Content.GetType() == typeof(XmlSchemaComplexContentExtension))
{
XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)complexContent.Content;
// Add Attributes
foreach (XmlSchemaAttribute attribute in extension.Attributes)
{
WriteAttributeField(attribute, codeType, attribute.DefaultValue);
}
// (Mod:11-26-08) If the particle is null return after adding attributes. The derived type is does not change the base type.
if (extension.Particle == null)
return;
// If extension has sequence particles
if (extension.Particle.GetType() == typeof(XmlSchemaSequence))
{
ProcessSequence((XmlSchemaSequence)extension.Particle, codeType);
}
else if (extension.Particle.GetType() == typeof(XmlSchemaChoice))
{
ProcessChoice((XmlSchemaChoice)extension.Particle, codeType);
}
else if (extension.Particle.GetType() == typeof(XmlSchemaAll))
{
ProcessAll((XmlSchemaAll)extension.Particle, codeType);
}
// Add anyAttribute if not null
if (extension.AnyAttribute != null)
WriteAnyAttribute(extension.AnyAttribute, codeType);
}
// Else if this is a type restriction
else if (complexContent.Content.GetType() == typeof(XmlSchemaComplexContentRestriction))
{
// need to add code to handle complex type restrictions here
XmlSchemaComplexContentRestriction restriction = (XmlSchemaComplexContentRestriction)complexContent.Content;
// (Mod:11-26-08) If the particle is null return after adding attributes. The derived type is does not change the base type.
if (restriction.Particle == null)
return;
}
}
示例14: GetChildElementCompletionData
XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaComplexContent complexContent, string prefix)
{
XmlCompletionDataCollection data = new XmlCompletionDataCollection();
XmlSchemaComplexContentExtension extension = complexContent.Content as XmlSchemaComplexContentExtension;
if (extension != null) {
data = GetChildElementCompletionData(extension, prefix);
} else {
XmlSchemaComplexContentRestriction restriction = complexContent.Content as XmlSchemaComplexContentRestriction;
if (restriction != null) {
data = GetChildElementCompletionData(restriction, prefix);
}
}
return data;
}
示例15: AddAppSequenceType
static void AddAppSequenceType(DiscoveryVersion discoveryVersion, XmlSchema schema)
{
//<xs:complexType name="AppSequenceType" >
XmlSchemaComplexType appSequenceType = new XmlSchemaComplexType();
appSequenceType.Name = ProtocolStrings.SchemaNames.AppSequenceType;
// <xs:complexContent>
XmlSchemaComplexContent complexContent = new XmlSchemaComplexContent();
appSequenceType.ContentModel = complexContent;
// <xs:restriction base="xs:anyType" >
XmlSchemaComplexContentRestriction contentRestriction = new XmlSchemaComplexContentRestriction();
complexContent.Content = contentRestriction;
contentRestriction.BaseTypeName = discoveryVersion.Implementation.QualifiedNames.AnyType;
// <xs:attribute name="InstanceId" type="xs:unsignedInt" use="required" />
XmlSchemaAttribute instanceId = new XmlSchemaAttribute();
instanceId.Name = ProtocolStrings.SchemaNames.AppSequenceInstanceId;
instanceId.SchemaTypeName = discoveryVersion.Implementation.QualifiedNames.UnsignedIntType;
instanceId.Use = XmlSchemaUse.Required;
// <xs:attribute name="SequenceId" type="xs:anyURI" />
XmlSchemaAttribute sequenceId = new XmlSchemaAttribute();
sequenceId.Name = ProtocolStrings.SchemaNames.AppSequenceSequenceId;
sequenceId.SchemaTypeName = discoveryVersion.Implementation.QualifiedNames.AnyUriType;
// <xs:attribute name="MessageNumber" type="xs:unsignedInt" use="required" />
XmlSchemaAttribute messageNumber = new XmlSchemaAttribute();
messageNumber.Name = ProtocolStrings.SchemaNames.AppSequenceMessageNumber;
messageNumber.SchemaTypeName = discoveryVersion.Implementation.QualifiedNames.UnsignedIntType;
messageNumber.Use = XmlSchemaUse.Required;
// <xs:anyAttribute namespace="##other" processContents="lax" />
XmlSchemaAnyAttribute anyAttribue = new XmlSchemaAnyAttribute();
anyAttribue.Namespace = "##other";
anyAttribue.ProcessContents = XmlSchemaContentProcessing.Lax;
contentRestriction.Attributes.Add(instanceId);
contentRestriction.Attributes.Add(sequenceId);
contentRestriction.Attributes.Add(messageNumber);
contentRestriction.AnyAttribute = anyAttribue;
schema.Items.Add(appSequenceType);
}