本文整理汇总了C#中System.Xml.Schema.XmlSchemaSequence类的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaSequence类的具体用法?C# XmlSchemaSequence怎么用?C# XmlSchemaSequence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlSchemaSequence类属于System.Xml.Schema命名空间,在下文中一共展示了XmlSchemaSequence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AndSchema
public static XmlSchemaElement AndSchema()
{
var type = new XmlSchemaComplexType();
var any = new XmlSchemaAny();
any.MinOccurs = 1;
any.MaxOccursString = "unbounded";
any.ProcessContents = XmlSchemaContentProcessing.Strict;
any.Namespace = "##local";
var sequence = new XmlSchemaSequence();
type.Particle = sequence;
sequence.Items.Add(any);
var attrib = new XmlSchemaAttribute();
attrib.Name = "expressionLanguage";
attrib.Use = XmlSchemaUse.Optional;
attrib.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
type.Attributes.Add(attrib);
attrib = new XmlSchemaAttribute();
attrib.Name = "failMessage";
attrib.Use = XmlSchemaUse.Optional;
attrib.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
type.Attributes.Add(attrib);
var element = new XmlSchemaElement();
element.Name = "and";
element.SchemaType = type;
return element;
}
示例2: CreateXmlSchemaForIndicatorsInGroup
/// <summary>
/// Формируем XmlSchema для правильного отображения индикаторов группы в VGridControl
/// </summary>
/// <param name="elmList">названия всех по</param>
/// <returns>Возвращаем поток в который записана XmlSchema</returns>
public static MemoryStream CreateXmlSchemaForIndicatorsInGroup(List<string[]> elmList)
{
var xmlSchema = new XmlSchema();
// <xs:element name="root">
var elementRoot = new XmlSchemaElement();
xmlSchema.Items.Add(elementRoot);
elementRoot.Name = "root";
// <xs:complexType>
var complexType = new XmlSchemaComplexType();
elementRoot.SchemaType = complexType;
// <xs:choice minOccurs="0" maxOccurs="unbounded">
var choice = new XmlSchemaChoice();
complexType.Particle = choice;
choice.MinOccurs = 0;
choice.MaxOccursString = "unbounded";
// <xs:element name="record">
var elementRecord = new XmlSchemaElement();
choice.Items.Add(elementRecord);
elementRecord.Name = "record";
// <xs:complexType>
var complexType2 = new XmlSchemaComplexType();
elementRecord.SchemaType = complexType2;
// <xs:sequence>
var sequence = new XmlSchemaSequence();
complexType2.Particle = sequence;
foreach (var el in elmList)
{
var element = new XmlSchemaElement();
sequence.Items.Add(element);
element.Name = el[0];
element.SchemaTypeName = new XmlQualifiedName(el[1], "http://www.w3.org/2001/XMLSchema");
}
var schemaSet = new XmlSchemaSet();
schemaSet.Add(xmlSchema);
schemaSet.Compile();
XmlSchema compiledSchema = null;
foreach (XmlSchema schema1 in schemaSet.Schemas())
compiledSchema = schema1;
var nsmgr = new XmlNamespaceManager(new NameTable());
nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
var ms = new MemoryStream();
if (compiledSchema != null) compiledSchema.Write(ms, nsmgr);
ms.Position = 0;
return ms;
}
示例3: GetStype
XmlSchemaComplexType GetStype ()
{
XmlSchemaSequence seq = new XmlSchemaSequence ();
seq.Items.Add (new XmlSchemaAny ());
XmlSchemaComplexType stype = new XmlSchemaComplexType ();
stype.Particle = seq;
return stype;
}
示例4: ReflectStringParametersMessage
internal void ReflectStringParametersMessage() {
Message inputMessage = InputMessage;
foreach (ParameterInfo parameterInfo in Method.InParameters) {
MessagePart part = new MessagePart();
part.Name = XmlConvert.EncodeLocalName(parameterInfo.Name);
if (parameterInfo.ParameterType.IsArray) {
string typeNs = DefaultNamespace;
if (typeNs.EndsWith("/", StringComparison.Ordinal))
typeNs += "AbstractTypes";
else
typeNs += "/AbstractTypes";
string typeName = "StringArray";
if (!ServiceDescription.Types.Schemas.Contains(typeNs)) {
XmlSchema schema = new XmlSchema();
schema.TargetNamespace = typeNs;
ServiceDescription.Types.Schemas.Add(schema);
XmlSchemaElement element = new XmlSchemaElement();
element.Name = "String";
element.SchemaTypeName = new XmlQualifiedName("string", XmlSchema.Namespace);
element.MinOccurs = decimal.Zero;
element.MaxOccurs = decimal.MaxValue;
XmlSchemaSequence all = new XmlSchemaSequence();
all.Items.Add(element);
XmlSchemaComplexContentRestriction restriction = new XmlSchemaComplexContentRestriction();
restriction.BaseTypeName = new XmlQualifiedName(Soap.ArrayType, Soap.Encoding);
restriction.Particle = all;
XmlSchemaImport import = new XmlSchemaImport();
import.Namespace = restriction.BaseTypeName.Namespace;
XmlSchemaComplexContent model = new XmlSchemaComplexContent();
model.Content = restriction;
XmlSchemaComplexType type = new XmlSchemaComplexType();
type.Name = typeName;
type.ContentModel = model;
schema.Items.Add(type);
schema.Includes.Add(import);
}
part.Type = new XmlQualifiedName(typeName, typeNs);
}
else {
part.Type = new XmlQualifiedName("string", XmlSchema.Namespace);
}
inputMessage.Parts.Add(part);
}
}
示例5: CheckIfCollection
private bool CheckIfCollection(XmlSchemaSequence rootSequence)
{
if ((rootSequence.Items == null) || (rootSequence.Items.Count == 0))
{
return false;
}
this.RemoveOptionalUnknownSerializationElements(rootSequence.Items);
if (rootSequence.Items.Count != 1)
{
return false;
}
XmlSchemaObject obj2 = rootSequence.Items[0];
if (!(obj2 is XmlSchemaElement))
{
return false;
}
XmlSchemaElement element = (XmlSchemaElement) obj2;
if (!(element.MaxOccursString == "unbounded"))
{
return (element.MaxOccurs > 1M);
}
return true;
}
示例6: CreateAnyType
private static XmlSchemaComplexType CreateAnyType(XmlSchemaContentProcessing processContents)
{
XmlSchemaComplexType localAnyType = new XmlSchemaComplexType();
localAnyType.SetQualifiedName(DatatypeImplementation.QnAnyType);
XmlSchemaAny anyElement = new XmlSchemaAny();
anyElement.MinOccurs = decimal.Zero;
anyElement.MaxOccurs = decimal.MaxValue;
anyElement.ProcessContents = processContents;
anyElement.BuildNamespaceList(null);
XmlSchemaSequence seq = new XmlSchemaSequence();
seq.Items.Add(anyElement);
localAnyType.SetContentTypeParticle(seq);
localAnyType.SetContentType(XmlSchemaContentType.Mixed);
localAnyType.ElementDecl = SchemaElementDecl.CreateAnyTypeElementDecl();
localAnyType.ElementDecl.SchemaType = localAnyType;
//Create contentValidator for Any
ParticleContentValidator contentValidator = new ParticleContentValidator(XmlSchemaContentType.Mixed);
contentValidator.Start();
contentValidator.OpenGroup();
contentValidator.AddNamespaceList(anyElement.NamespaceList, anyElement);
contentValidator.AddStar();
contentValidator.CloseGroup();
ContentValidator anyContentValidator = contentValidator.Finish(true);
localAnyType.ElementDecl.ContentValidator = anyContentValidator;
XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute();
anyAttribute.ProcessContents = processContents;
anyAttribute.BuildNamespaceList(null);
localAnyType.SetAttributeWildcard(anyAttribute);
localAnyType.ElementDecl.AnyAttribute = anyAttribute;
return localAnyType;
}
示例7: GetClassSchema
/// <summary>
/// Gets the class schema.
/// </summary>
/// <param name="t">The t.</param>
/// <returns>schema info</returns>
public static SchemaInfo GetClassSchema(this Type t)
{
var schemaInfo = new SchemaInfo();
var classType = new XmlSchemaComplexType
{
Name = t.Name
};
var attribData = t.GetCustomAttributeDataOfType(typeof(DataContractAttribute));
if (attribData.NamedArguments != null && attribData.NamedArguments.Count > 0)
{
foreach (var p1 in attribData.NamedArguments)
{
switch (p1.MemberInfo.Name)
{
case "Namespace":
schemaInfo.Schema.TargetNamespace = p1.TypedValue.Value as string;
break;
}
}
}
var sequence = new XmlSchemaSequence();
classType.Particle = sequence;
var propList = t.GetProperties();
foreach (var p1 in propList)
{
var el = new XmlSchemaElement
{
Name = p1.Name,
MinOccurs = 0
};
var xmlName = p1.PropertyType.XmlName();
if (xmlName != null)
{
el.SchemaTypeName = xmlName;
}
else
{
if (p1.PropertyType.IsListType())
{
// what is this a list of?
if (p1.PropertyType.FullName != null)
{
var pr = Primitive2Xml.XmlName(InternalType(p1.PropertyType.FullName, false));
if (pr != null)
{
el.SchemaTypeName = new XmlQualifiedName("ArrayOf" + pr.Name);
schemaInfo.CustomTypes.Add(el.SchemaTypeName);
}
else
{
var schName = InternalType(p1.PropertyType.FullName, true);
el.SchemaTypeName = new XmlQualifiedName("ArrayOf" + schName);
schemaInfo.CustomTypes.Add(new XmlQualifiedName(schName));
schemaInfo.CustomTypes.Add(el.SchemaTypeName);
}
}
}
else if (p1.PropertyType.Name.Contains("Nullable"))
{
// what is this a nullable of?
if (p1.PropertyType.FullName != null)
{
var pr = Primitive2Xml.XmlName(InternalType(p1.PropertyType.FullName, false));
if (pr != null)
{
el.SchemaTypeName = pr;
}
else
{
var schName = InternalType(p1.PropertyType.FullName, true);
el.SchemaTypeName = new XmlQualifiedName(schName);
schemaInfo.CustomTypes.Add(el.SchemaTypeName);
}
el.IsNillable = true;
}
}
else
{
el.SchemaTypeName = new XmlQualifiedName(p1.PropertyType.Name);
schemaInfo.CustomTypes.Add(el.SchemaTypeName);
}
}
// get data member
var attrData = p1.GetCustomAttributeDataOfType(typeof(DataMemberAttribute));
if (attrData != null && attrData.NamedArguments != null
&& attrData.NamedArguments.Count > 0)
{
//.........这里部分代码省略.........
示例8: GetSchema
public XmlSchema GetSchema ()
{
XmlSchema s = new XmlSchema ();
s.TargetNamespace = "http://www.go-mono.org/schemas";
s.Id = "monoschema";
XmlSchemaElement e = new XmlSchemaElement ();
e.Name = "data";
s.Items.Add (e);
XmlSchemaComplexType cs = new XmlSchemaComplexType ();
XmlSchemaSequence seq = new XmlSchemaSequence ();
XmlSchemaAny any = new XmlSchemaAny ();
any.MinOccurs = 0;
any.MaxOccurs = decimal.MaxValue;
seq.Items.Add (any);
cs.Particle = seq;
e.SchemaType = cs;
return s;
}
示例9: ExportParameters
QName ExportParameters (MessageBodyDescription msgbody, string name, string ns)
{
XmlSchema xs = GetSchema (ns);
//FIXME: Extract to a HasElement method ?
foreach (XmlSchemaObject o in xs.Items) {
XmlSchemaElement e = o as XmlSchemaElement;
if (e == null)
continue;
if (e.Name == name)
throw new InvalidOperationException (String.Format (
"Message element named '{0}:{1}' has already been exported.",
ns, name));
}
//Create the element for "parameters"
XmlSchemaElement schema_element = new XmlSchemaElement ();
schema_element.Name = name;
XmlSchemaComplexType complex_type = new XmlSchemaComplexType ();
//Generate Sequence representing the message/parameters
//FIXME: MessageContractAttribute
XmlSchemaSequence sequence = new XmlSchemaSequence ();
XmlSchemaElement element = null;
if (msgbody.ReturnValue == null) {
//parameters
foreach (MessagePartDescription part in msgbody.Parts) {
if (part.Type == null)
//FIXME: Eg. when WsdlImporter is used to import a wsdl
throw new NotImplementedException ();
element = GetSchemaElementForPart (part, xs);
sequence.Items.Add (element);
}
} else {
//ReturnValue
if (msgbody.ReturnValue.Type != typeof (void)) {
element = GetSchemaElementForPart (msgbody.ReturnValue, xs);
sequence.Items.Add (element);
}
}
complex_type.Particle = sequence;
schema_element.SchemaType = complex_type;
xs.Items.Add (schema_element);
GeneratedXmlSchemas.Reprocess (xs);
return new QName (schema_element.Name, xs.TargetNamespace);
}
示例10: IsSequenceFromChoice
private bool IsSequenceFromChoice(XmlSchemaSequence derivedSequence, XmlSchemaChoice baseChoice)
{
decimal num;
decimal num2;
this.CalculateSequenceRange(derivedSequence, out num, out num2);
if (!this.IsValidOccurrenceRangeRestriction(num, num2, baseChoice.MinOccurs, baseChoice.MaxOccurs) || (derivedSequence.Items.Count > baseChoice.Items.Count))
{
return false;
}
for (int i = 0; i < derivedSequence.Items.Count; i++)
{
if (this.GetMappingParticle((XmlSchemaParticle) derivedSequence.Items[i], baseChoice.Items) < 0)
{
return false;
}
}
return true;
}
示例11: CannonicalizeAll
private XmlSchemaParticle CannonicalizeAll(XmlSchemaAll all, bool root, bool substitution)
{
if (all.Items.Count > 0)
{
XmlSchemaAll all2 = new XmlSchemaAll {
MinOccurs = all.MinOccurs,
MaxOccurs = all.MaxOccurs,
SourceUri = all.SourceUri,
LineNumber = all.LineNumber,
LinePosition = all.LinePosition
};
for (int i = 0; i < all.Items.Count; i++)
{
XmlSchemaParticle item = this.CannonicalizeParticle((XmlSchemaElement) all.Items[i], false, substitution);
if (item != XmlSchemaParticle.Empty)
{
all2.Items.Add(item);
}
}
all = all2;
}
if (all.Items.Count == 0)
{
return XmlSchemaParticle.Empty;
}
if (root && (all.Items.Count == 1))
{
XmlSchemaSequence sequence = new XmlSchemaSequence {
MinOccurs = all.MinOccurs,
MaxOccurs = all.MaxOccurs
};
sequence.Items.Add((XmlSchemaParticle) all.Items[0]);
return sequence;
}
if ((!root && (all.Items.Count == 1)) && ((all.MinOccurs == 1M) && (all.MaxOccurs == 1M)))
{
return (XmlSchemaParticle) all.Items[0];
}
if (!root)
{
base.SendValidationEvent("Sch_NotAllAlone", all);
return XmlSchemaParticle.Empty;
}
return all;
}
示例12: CompileComplexContentExtension
private void CompileComplexContentExtension(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentExtension complexExtension)
{
XmlSchemaComplexType redefined = null;
if ((complexType.Redefined != null) && (complexExtension.BaseTypeName == complexType.Redefined.QualifiedName))
{
redefined = (XmlSchemaComplexType) complexType.Redefined;
this.CompileComplexType(redefined);
}
else
{
redefined = this.GetComplexType(complexExtension.BaseTypeName);
if (redefined == null)
{
base.SendValidationEvent("Sch_UndefBaseExtension", complexExtension.BaseTypeName.ToString(), complexExtension);
return;
}
}
if (((redefined != null) && (redefined.ElementDecl != null)) && (redefined.ContentType == XmlSchemaContentType.TextOnly))
{
base.SendValidationEvent("Sch_NotComplexContent", complexType);
}
else
{
complexType.SetBaseSchemaType(redefined);
if ((redefined.FinalResolved & XmlSchemaDerivationMethod.Extension) != XmlSchemaDerivationMethod.Empty)
{
base.SendValidationEvent("Sch_BaseFinalExtension", complexType);
}
this.CompileLocalAttributes(redefined, complexType, complexExtension.Attributes, complexExtension.AnyAttribute, XmlSchemaDerivationMethod.Extension);
XmlSchemaParticle contentTypeParticle = redefined.ContentTypeParticle;
XmlSchemaParticle item = this.CannonicalizeParticle(complexExtension.Particle, true, true);
if (contentTypeParticle != XmlSchemaParticle.Empty)
{
if (item != XmlSchemaParticle.Empty)
{
XmlSchemaSequence particle = new XmlSchemaSequence();
particle.Items.Add(contentTypeParticle);
particle.Items.Add(item);
complexType.SetContentTypeParticle(this.CompileContentTypeParticle(particle, false));
}
else
{
complexType.SetContentTypeParticle(contentTypeParticle);
}
XmlSchemaContentType contentType = this.GetSchemaContentType(complexType, complexContent, item);
if (contentType == XmlSchemaContentType.Empty)
{
contentType = redefined.ContentType;
}
complexType.SetContentType(contentType);
if (complexType.ContentType != redefined.ContentType)
{
base.SendValidationEvent("Sch_DifContentType", complexType);
}
}
else
{
complexType.SetContentTypeParticle(item);
complexType.SetContentType(this.GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle));
}
complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension);
}
}
示例13: IsSequenceFromAll
private bool IsSequenceFromAll(XmlSchemaSequence derivedSequence, XmlSchemaAll baseAll) {
if (!IsValidOccurrenceRangeRestriction(derivedSequence, baseAll) || derivedSequence.Items.Count > baseAll.Items.Count) {
return false;
}
BitSet map = new BitSet(baseAll.Items.Count);
for (int j = 0; j < derivedSequence.Items.Count; ++j) {
int i = GetMappingParticle((XmlSchemaParticle)derivedSequence.Items[j], baseAll.Items);
if (i >= 0) {
if (map[i]) {
return false;
}
else {
map.Set(i);
}
}
else {
return false;
}
}
for (int i = 0; i < baseAll.Items.Count; i++) {
if (!map[i] && !IsParticleEmptiable((XmlSchemaParticle)baseAll.Items[i])) {
return false;
}
}
return true;
}
示例14: IsElementFromGroupBase
private bool IsElementFromGroupBase(XmlSchemaElement derivedElement, XmlSchemaGroupBase baseGroupBase) {
if (baseGroupBase is XmlSchemaSequence) {
XmlSchemaSequence virtualSeq = new XmlSchemaSequence();
virtualSeq.MinOccurs = 1;
virtualSeq.MaxOccurs = 1;
virtualSeq.Items.Add(derivedElement);
if (IsGroupBaseFromGroupBase((XmlSchemaGroupBase)virtualSeq, baseGroupBase, true)) {
return true;
}
restrictionErrorMsg = Res.GetString(Res.Sch_ElementFromGroupBase1, derivedElement.QualifiedName.ToString(), derivedElement.LineNumber.ToString(NumberFormatInfo.InvariantInfo), derivedElement.LinePosition.ToString(NumberFormatInfo.InvariantInfo), baseGroupBase.LineNumber.ToString(NumberFormatInfo.InvariantInfo), baseGroupBase.LinePosition.ToString(NumberFormatInfo.InvariantInfo));
}
else if (baseGroupBase is XmlSchemaChoice) {
XmlSchemaChoice virtualChoice = new XmlSchemaChoice();
virtualChoice.MinOccurs = 1;
virtualChoice.MaxOccurs = 1;
virtualChoice.Items.Add(derivedElement);
if (IsGroupBaseFromGroupBase((XmlSchemaGroupBase)virtualChoice, baseGroupBase, false)) {
return true;
}
restrictionErrorMsg = Res.GetString(Res.Sch_ElementFromGroupBase2, derivedElement.QualifiedName.ToString(), derivedElement.LineNumber.ToString(NumberFormatInfo.InvariantInfo), derivedElement.LinePosition.ToString(NumberFormatInfo.InvariantInfo), baseGroupBase.LineNumber.ToString(NumberFormatInfo.InvariantInfo), baseGroupBase.LinePosition.ToString(NumberFormatInfo.InvariantInfo));
}
else if (baseGroupBase is XmlSchemaAll) {
XmlSchemaAll virtualAll = new XmlSchemaAll();
virtualAll.MinOccurs = 1;
virtualAll.MaxOccurs = 1;
virtualAll.Items.Add(derivedElement);
if (IsGroupBaseFromGroupBase((XmlSchemaGroupBase)virtualAll, baseGroupBase, true)) {
return true;
}
restrictionErrorMsg = Res.GetString(Res.Sch_ElementFromGroupBase3, derivedElement.QualifiedName.ToString(), derivedElement.LineNumber.ToString(NumberFormatInfo.InvariantInfo), derivedElement.LinePosition.ToString(NumberFormatInfo.InvariantInfo), baseGroupBase.LineNumber.ToString(NumberFormatInfo.InvariantInfo), baseGroupBase.LinePosition.ToString(NumberFormatInfo.InvariantInfo));
}
return false;
}
示例15: ImportMembersMapping
/// <include file='doc\SoapSchemaImporter.uex' path='docs/doc[@for="SoapSchemaImporter.ImportMembersMapping3"]/*' />
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public XmlMembersMapping ImportMembersMapping(string name, string ns, SoapSchemaMember[] members, bool hasWrapperElement, Type baseType, bool baseTypeCanBeIndirect) {
XmlSchemaComplexType type = new XmlSchemaComplexType();
XmlSchemaSequence seq = new XmlSchemaSequence();
type.Particle = seq;
foreach (SoapSchemaMember member in members) {
XmlSchemaElement element = new XmlSchemaElement();
element.Name = member.MemberName;
element.SchemaTypeName = member.MemberType;
seq.Items.Add(element);
}
CodeIdentifiers identifiers = new CodeIdentifiers();
identifiers.UseCamelCasing = true;
MembersMapping mapping = new MembersMapping();
mapping.TypeDesc = Scope.GetTypeDesc(typeof(object[]));
mapping.Members = ImportTypeMembers(type, ns, identifiers);
mapping.HasWrapperElement = hasWrapperElement;
if (baseType != null) {
for (int i = 0; i < mapping.Members.Length; i++) {
MemberMapping member = mapping.Members[i];
if (member.Accessor.Mapping is StructMapping)
MakeDerived((StructMapping)member.Accessor.Mapping, baseType, baseTypeCanBeIndirect);
}
}
ElementAccessor accessor = new ElementAccessor();
accessor.IsSoap = true;
accessor.Name = name;
accessor.Namespace = ns;
accessor.Mapping = mapping;
accessor.IsNullable = false;
accessor.Form = XmlSchemaForm.Qualified;
return new XmlMembersMapping(Scope, accessor, XmlMappingAccess.Read | XmlMappingAccess.Write);
}