Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
XmlSchemaExporter.cs
Go to the documentation of this file.
5
7
8public class XmlSchemaExporter
9{
10 private readonly XmlSchemas _schemas;
11
12 private readonly Hashtable _elements = new Hashtable();
13
14 private readonly Hashtable _attributes = new Hashtable();
15
16 private readonly Hashtable _types = new Hashtable();
17
18 private readonly Hashtable _references = new Hashtable();
19
20 private bool _needToExportRoot;
21
23
25 {
26 _schemas = schemas;
27 }
28
36
38 {
39 xmlMembersMapping.CheckShallow();
42 if (membersMapping.Members.Length == 1 && membersMapping.Members[0].Elements[0].Mapping is SpecialMapping)
43 {
46 if (xmlSchemaType != null && xmlSchemaType.Name != null && xmlSchemaType.Name.Length > 0)
47 {
49 AddSchemaItem(xmlSchemaType, xmlMembersMapping.Accessor.Namespace, null);
50 }
52 return new XmlQualifiedName(xmlMembersMapping.Accessor.Name, xmlMembersMapping.Accessor.Namespace);
53 }
54 return null;
55 }
56
61
63 {
64 xmlMembersMapping.CheckShallow();
67 if (membersMapping.HasWrapperElement && exportEnclosingType)
68 {
70 }
71 else
72 {
75 {
76 if (memberMapping.Attribute != null)
77 {
79 }
80 if (memberMapping.Text != null)
81 {
83 }
84 if (memberMapping.Elements != null && memberMapping.Elements.Length != 0)
85 {
86 if (memberMapping.TypeDesc.IsArrayLike && !(memberMapping.Elements[0].Mapping is ArrayMapping))
87 {
89 }
91 {
92 ExportElement(memberMapping.Elements[0]);
93 }
94 else
95 {
96 ExportMapping(memberMapping.Elements[0].Mapping, memberMapping.Elements[0].Namespace, memberMapping.Elements[0].Any);
97 }
98 }
99 }
100 }
102 }
103
104 private static XmlSchemaType FindSchemaType(string name, XmlSchemaObjectCollection items)
105 {
106 foreach (XmlSchemaObject item in items)
107 {
109 {
110 return xmlSchemaType;
111 }
112 }
113 return null;
114 }
115
116 private static bool IsAnyType(XmlSchemaType schemaType, bool mixed, bool unbounded)
117 {
119 {
120 if (xmlSchemaComplexType.IsMixed != mixed)
121 {
122 return false;
123 }
125 {
127 if (xmlSchemaSequence.Items.Count == 1 && xmlSchemaSequence.Items[0] is XmlSchemaAny)
128 {
130 return unbounded == xmlSchemaAny.IsMultipleOccurrence;
131 }
132 }
133 }
134 return false;
135 }
136
137 public string ExportAnyType(string? ns)
138 {
139 string text = "any";
140 int num = 0;
142 if (xmlSchema != null)
143 {
144 while (true)
145 {
147 if (xmlSchemaType == null)
148 {
149 break;
150 }
151 if (IsAnyType(xmlSchemaType, mixed: true, unbounded: true))
152 {
153 return text;
154 }
155 num++;
156 text = "any" + num.ToString(CultureInfo.InvariantCulture);
157 }
158 }
165 xmlSchemaAny.MaxOccurs = decimal.MaxValue;
169 return text;
170 }
171
173 {
174 if (members.Count == 1 && members[0].Any && members[0].ElementName.Length == 0)
175 {
177 string @namespace = xmlMemberMapping.Namespace;
178 bool flag = xmlMemberMapping.Mapping.TypeDesc.IsArrayLike;
179 bool flag2 = ((flag && xmlMemberMapping.Mapping.TypeDesc.ArrayElementTypeDesc != null) ? xmlMemberMapping.Mapping.TypeDesc.ArrayElementTypeDesc.IsMixed : xmlMemberMapping.Mapping.TypeDesc.IsMixed);
180 if (flag2 && xmlMemberMapping.Mapping.TypeDesc.IsMixed)
181 {
182 flag = true;
183 }
184 string text = (flag2 ? "any" : (flag ? "anyElements" : "anyElement"));
185 string text2 = text;
186 int num = 0;
187 XmlSchema xmlSchema = _schemas[@namespace];
188 if (xmlSchema != null)
189 {
190 while (true)
191 {
192 XmlSchemaType xmlSchemaType = FindSchemaType(text2, xmlSchema.Items);
193 if (xmlSchemaType == null)
194 {
195 break;
196 }
197 if (IsAnyType(xmlSchemaType, flag2, flag))
198 {
199 return text2;
200 }
201 num++;
202 text2 = text + num.ToString(CultureInfo.InvariantCulture);
203 }
204 }
205 XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType();
206 xmlSchemaComplexType.Name = text2;
207 xmlSchemaComplexType.IsMixed = flag2;
208 XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
209 XmlSchemaAny xmlSchemaAny = new XmlSchemaAny();
210 xmlSchemaAny.MinOccurs = 0m;
211 if (flag)
212 {
213 xmlSchemaAny.MaxOccurs = decimal.MaxValue;
214 }
215 xmlSchemaSequence.Items.Add(xmlSchemaAny);
216 xmlSchemaComplexType.Particle = xmlSchemaSequence;
217 AddSchemaItem(xmlSchemaComplexType, @namespace, null);
218 return text2;
219 }
220 return null;
221 }
222
223 private void CheckScope(TypeScope scope)
224 {
225 if (_scope == null)
226 {
227 _scope = scope;
228 }
229 else if (_scope != scope)
230 {
232 }
233 }
234
236 {
237 if (!accessor.Mapping.IncludeInSchema && !accessor.Mapping.TypeDesc.IsRoot)
238 {
239 return null;
240 }
241 if (accessor.Any && accessor.Name.Length == 0)
242 {
244 }
246 if (xmlSchemaElement != null)
247 {
248 return xmlSchemaElement;
249 }
255 AddSchemaItem(xmlSchemaElement, accessor.Namespace, null);
257 return xmlSchemaElement;
258 }
259
261 {
262 if (mapping.IsAnonymousType)
263 {
264 return;
265 }
266 string typeName = mapping.TypeName;
268 if (xmlSchema == null)
269 {
270 return;
271 }
272 foreach (XmlSchemaObject item in xmlSchema.Items)
273 {
275 {
277 }
278 }
279 }
280
290
291 private void AddSchemaItem(XmlSchemaObject item, string ns, string referencingNs)
292 {
294 if (xmlSchema == null)
295 {
296 xmlSchema = AddSchema(ns);
297 }
299 {
301 if (xmlSchemaElement.Form == XmlSchemaForm.Unqualified)
302 {
304 }
306 }
307 else if (item is XmlSchemaAttribute)
308 {
310 if (xmlSchemaAttribute.Form == XmlSchemaForm.Unqualified)
311 {
313 }
315 }
316 xmlSchema.Items.Add(item);
318 }
319
320 private void AddSchemaImport(string ns, string referencingNs)
321 {
322 if (referencingNs == null || NamespacesEqual(ns, referencingNs))
323 {
324 return;
325 }
327 if (xmlSchema == null)
328 {
330 }
331 if (FindImport(xmlSchema, ns) == null)
332 {
334 if (ns != null && ns.Length > 0)
335 {
337 }
338 xmlSchema.Includes.Add(xmlSchemaImport);
339 }
340 }
341
342 private static bool NamespacesEqual(string ns1, string ns2)
343 {
344 if (ns1 == null || ns1.Length == 0)
345 {
346 if (ns2 != null)
347 {
348 return ns2.Length == 0;
349 }
350 return true;
351 }
352 return ns1 == ns2;
353 }
354
355 private bool SchemaContainsItem(XmlSchemaObject item, string ns)
356 {
357 return _schemas[ns]?.Items.Contains(item) ?? false;
358 }
359
361 {
362 foreach (XmlSchemaObject include in schema.Includes)
363 {
365 {
367 if (NamespacesEqual(xmlSchemaImport.Namespace, ns))
368 {
369 return xmlSchemaImport;
370 }
371 }
372 }
373 return null;
374 }
375
376 private void ExportMapping(Mapping mapping, string ns, bool isAny)
377 {
379 {
381 return;
382 }
384 {
386 return;
387 }
389 {
391 return;
392 }
394 {
396 return;
397 }
399 {
401 return;
402 }
404 {
405 ExportMapping(((NullableMapping)mapping).BaseMapping, ns, isAny);
406 return;
407 }
408 throw new ArgumentException(System.SR.XmlInternalError, "mapping");
409 }
410
411 private void ExportElementMapping(XmlSchemaElement element, Mapping mapping, string ns, bool isAny)
412 {
414 {
416 }
417 else if (mapping is PrimitiveMapping)
418 {
420 if (primitiveMapping.IsAnonymousType)
421 {
423 }
424 else
425 {
427 }
428 }
429 else if (mapping is StructMapping)
430 {
432 }
433 else if (mapping is MembersMapping)
434 {
436 }
437 else if (mapping is SpecialMapping)
438 {
440 }
441 else
442 {
444 {
445 throw new ArgumentException(System.SR.XmlInternalError, "mapping");
446 }
447 ExportElementMapping(element, ((NullableMapping)mapping).BaseMapping, ns, isAny);
448 }
449 }
450
452 {
454 if (!SchemaContainsItem(item, "http://microsoft.com/wsdl/types/"))
455 {
456 AddSchemaItem(item, "http://microsoft.com/wsdl/types/", ns);
457 }
458 else
459 {
460 AddSchemaImport(mapping.Namespace, ns);
461 }
462 return new XmlQualifiedName(mapping.TypeDesc.DataType.Name, "http://microsoft.com/wsdl/types/");
463 }
464
466 {
467 switch (mapping.TypeDesc.Kind)
468 {
469 case TypeKind.Node:
470 {
472 xmlSchemaComplexType4.IsMixed = mapping.TypeDesc.IsMixed;
475 if (isAny)
476 {
479 xmlSchemaAny3.MaxOccurs = decimal.MaxValue;
480 }
483 if (element != null)
484 {
486 }
488 }
489 case TypeKind.Serializable:
490 {
492 if (serializableMapping.IsAny)
493 {
495 xmlSchemaComplexType.IsMixed = mapping.TypeDesc.IsMixed;
498 if (isAny)
499 {
502 xmlSchemaAny.MaxOccurs = decimal.MaxValue;
503 }
504 if (serializableMapping.NamespaceList.Length > 0)
505 {
507 }
509 if (serializableMapping.Schemas != null)
510 {
511 foreach (XmlSchema item in serializableMapping.Schemas.Schemas())
512 {
513 if (item.TargetNamespace != "http://www.w3.org/2001/XMLSchema")
514 {
515 _schemas.Add(item, delay: true);
516 AddSchemaImport(item.TargetNamespace, ns);
517 }
518 }
519 }
522 if (element != null)
523 {
525 }
527 }
528 if (serializableMapping.XsiType != null || serializableMapping.XsdType != null)
529 {
531 foreach (XmlSchema item2 in serializableMapping.Schemas.Schemas())
532 {
533 if (item2.TargetNamespace != "http://www.w3.org/2001/XMLSchema")
534 {
535 _schemas.Add(item2, delay: true);
536 AddSchemaImport(item2.TargetNamespace, ns);
537 if (!serializableMapping.XsiType.IsEmpty && serializableMapping.XsiType.Namespace == item2.TargetNamespace)
538 {
540 }
541 }
542 }
543 if (element != null)
544 {
546 if (element.SchemaTypeName.IsEmpty)
547 {
549 }
550 }
551 serializableMapping.CheckDuplicateElement(element, ns);
552 return xmlSchemaType;
553 }
554 if (serializableMapping.Schema != null)
555 {
561 string targetNamespace = serializableMapping.Schema.TargetNamespace;
564 if (xmlSchema3 == null)
565 {
567 }
568 else if (xmlSchema3 != serializableMapping.Schema)
569 {
571 }
572 if (element != null)
573 {
575 }
576 serializableMapping.CheckDuplicateElement(element, ns);
578 }
581 xmlSchemaElement.RefName = new XmlQualifiedName("schema", "http://www.w3.org/2001/XMLSchema");
584 xmlSchemaSequence3.Items.Add(new XmlSchemaAny());
586 AddSchemaImport("http://www.w3.org/2001/XMLSchema", ns);
587 if (element != null)
588 {
590 }
592 }
593 default:
594 throw new ArgumentException(System.SR.XmlInternalError, "mapping");
595 }
596 }
597
599 {
601 ExportTypeMembers(xmlSchemaComplexType, mapping.Members, mapping.TypeName, ns, hasSimpleContent: false, openModel: false);
602 if (mapping.XmlnsMember != null)
603 {
605 }
607 }
608
610 {
612 {
614 }
615 throw new InvalidOperationException(System.SR.Format(System.SR.XmlInternalErrorDetails, "Unsupported anonymous mapping type: " + mapping.ToString()));
616 }
617
619 {
621 {
623 return new XmlQualifiedName(xmlSchemaType.Name, mapping.Namespace);
624 }
625 if (mapping.TypeDesc.IsXsdType)
626 {
627 return new XmlQualifiedName(mapping.TypeDesc.DataType.Name, "http://www.w3.org/2001/XMLSchema");
628 }
630 }
631
632 private void ExportArrayMapping(ArrayMapping mapping, string ns, XmlSchemaElement element)
633 {
635 while (arrayMapping.Next != null)
636 {
638 }
640 if (xmlSchemaComplexType == null)
641 {
644 if (!mapping.IsAnonymousType)
645 {
648 }
649 if (!arrayMapping.IsAnonymousType)
650 {
652 }
655 if (xmlSchemaSequence.Items.Count > 0)
656 {
658 {
660 }
661 else
662 {
664 }
665 }
666 }
667 else
668 {
669 AddSchemaImport(mapping.Namespace, ns);
670 }
671 if (element != null)
672 {
673 if (mapping.IsAnonymousType)
674 {
676 }
677 else
678 {
680 }
681 }
682 }
683
685 {
686 if (accessors.Length == 0)
687 {
688 return;
689 }
690 if (accessors.Length == 1)
691 {
693 return;
694 }
697 xmlSchemaChoice.MinOccurs = ((!repeats) ? 1 : 0);
698 for (int i = 0; i < accessors.Length; i++)
699 {
701 }
702 if (xmlSchemaChoice.Items.Count > 0)
703 {
704 group.Items.Add(xmlSchemaChoice);
705 }
706 }
707
709 {
710 if (accessor == null)
711 {
712 return;
713 }
714 XmlSchemaObjectCollection attributes;
715 if (type.ContentModel != null)
716 {
717 if (type.ContentModel.Content is XmlSchemaComplexContentRestriction)
718 {
719 attributes = ((XmlSchemaComplexContentRestriction)type.ContentModel.Content).Attributes;
720 }
721 else if (type.ContentModel.Content is XmlSchemaComplexContentExtension)
722 {
723 attributes = ((XmlSchemaComplexContentExtension)type.ContentModel.Content).Attributes;
724 }
725 else
726 {
727 if (!(type.ContentModel.Content is XmlSchemaSimpleContentExtension))
728 {
729 throw new InvalidOperationException(System.SR.Format(System.SR.XmlInvalidContent, type.ContentModel.Content.GetType().Name));
730 }
731 attributes = ((XmlSchemaSimpleContentExtension)type.ContentModel.Content).Attributes;
732 }
733 }
734 else
735 {
736 attributes = type.Attributes;
737 }
738 if (accessor.IsSpecialXmlNamespace)
739 {
740 AddSchemaImport("http://www.w3.org/XML/1998/namespace", ns);
743 xmlSchemaAttribute.RefName = new XmlQualifiedName(accessor.Name, "http://www.w3.org/XML/1998/namespace");
744 attributes.Add(xmlSchemaAttribute);
745 return;
746 }
747 if (accessor.Any)
748 {
749 if (type.ContentModel == null)
750 {
752 return;
753 }
754 XmlSchemaContent content = type.ContentModel.Content;
756 {
759 }
760 else if (content is XmlSchemaComplexContentRestriction)
761 {
764 }
765 else if (type.ContentModel.Content is XmlSchemaSimpleContentExtension)
766 {
769 }
770 return;
771 }
774 if (!accessor.HasDefault && !valueTypeOptional && accessor.Mapping.TypeDesc.IsValueType)
775 {
777 }
779 if (accessor.Namespace == null || accessor.Namespace == ns)
780 {
782 if (xmlSchema == null)
783 {
785 }
786 else
787 {
788 xmlSchemaAttribute2.Form = ((accessor.Form != xmlSchema.AttributeFormDefault) ? accessor.Form : XmlSchemaForm.None);
789 }
790 attributes.Add(xmlSchemaAttribute2);
791 }
792 else
793 {
794 if (_attributes[accessor] == null)
795 {
800 }
804 attributes.Add(xmlSchemaAttribute3);
805 AddSchemaImport(accessor.Namespace, ns);
806 }
807 if (accessor.Mapping is PrimitiveMapping)
808 {
810 if (primitiveMapping.IsList)
811 {
814 if (primitiveMapping.IsAnonymousType)
815 {
817 }
818 else
819 {
821 }
824 }
825 else if (primitiveMapping.IsAnonymousType)
826 {
828 }
829 else
830 {
832 }
833 }
834 else if (!(accessor.Mapping is SpecialMapping))
835 {
837 }
838 if (accessor.HasDefault)
839 {
841 }
842 }
843
845 {
846 if (accessor.Any && accessor.Name.Length == 0)
847 {
851 if (accessor.Namespace != null && accessor.Namespace.Length > 0 && accessor.Namespace != ns)
852 {
854 }
855 group.Items.Add(xmlSchemaAny);
856 return;
857 }
859 int num = ((!(repeats || accessor.HasDefault || (!accessor.IsNullable && !accessor.Mapping.TypeDesc.IsValueType) || valueTypeOptional)) ? 1 : 0);
860 decimal maxOccurs = ((repeats || accessor.IsUnbounded) ? decimal.MaxValue : 1m);
861 if (xmlSchemaElement == null)
862 {
866 if (accessor.HasDefault)
867 {
869 }
870 if (accessor.IsTopLevelInSchema)
871 {
875 }
876 else
877 {
881 if (xmlSchema == null)
882 {
884 }
885 else
886 {
887 xmlSchemaElement.Form = ((accessor.Form != xmlSchema.ElementFormDefault) ? accessor.Form : XmlSchemaForm.None);
888 }
889 }
891 }
892 if (accessor.IsTopLevelInSchema)
893 {
898 group.Items.Add(xmlSchemaElement2);
899 AddSchemaImport(accessor.Namespace, ns);
900 }
901 else
902 {
903 group.Items.Add(xmlSchemaElement);
904 }
905 }
906
907 internal static string ExportDefaultValue(TypeMapping mapping, object value)
908 {
910 {
911 return null;
912 }
913 if (value == null || value == DBNull.Value)
914 {
915 return null;
916 }
918 {
921 if (enumMapping.IsFlags)
922 {
923 string[] array = new string[constants.Length];
924 long[] array2 = new long[constants.Length];
925 Hashtable hashtable = new Hashtable();
926 for (int i = 0; i < constants.Length; i++)
927 {
928 array[i] = constants[i].XmlName;
929 array2[i] = 1 << i;
930 hashtable.Add(constants[i].Name, array2[i]);
931 }
932 long num = XmlCustomFormatter.ToEnum((string)value, hashtable, enumMapping.TypeName, validate: false);
933 if (num == 0L)
934 {
935 return null;
936 }
937 return XmlCustomFormatter.FromEnum(num, array, array2, mapping.TypeDesc.FullName);
938 }
939 for (int j = 0; j < constants.Length; j++)
940 {
941 if (constants[j].Name == (string)value)
942 {
943 return constants[j].XmlName;
944 }
945 }
946 return null;
947 }
949 if (!primitiveMapping.TypeDesc.HasCustomFormatter)
950 {
951 if (primitiveMapping.TypeDesc.FormatterName == "String")
952 {
953 return (string)value;
954 }
956 MethodInfo method = typeFromHandle.GetMethod("ToString", new Type[1] { primitiveMapping.TypeDesc.Type });
957 if (method != null)
958 {
959 return (string)method.Invoke(typeFromHandle, new object[1] { value });
960 }
962 }
963 string text = XmlCustomFormatter.FromDefaultValue(value, primitiveMapping.TypeDesc.FormatterName);
964 if (text == null)
965 {
967 }
968 return text;
969 }
970
972 {
974 {
975 return;
976 }
977 foreach (TypeMapping typeMapping in typeScope.TypeMappings)
978 {
980 {
982 }
983 else if (typeMapping is ArrayMapping)
984 {
986 }
988 {
990 }
991 }
992 }
993
995 {
996 if (mapping.TypeDesc.IsRoot)
997 {
998 _needToExportRoot = true;
999 return XmlQualifiedName.Empty;
1000 }
1001 if (mapping.IsAnonymousType)
1002 {
1003 if (_references[mapping] != null)
1004 {
1005 throw new InvalidOperationException(System.SR.Format(System.SR.XmlCircularReference2, mapping.TypeDesc.Name, "AnonymousType", "false"));
1006 }
1008 }
1010 if (xmlSchemaComplexType == null)
1011 {
1012 if (!mapping.IncludeInSchema)
1013 {
1015 }
1018 if (!mapping.IsAnonymousType)
1019 {
1023 }
1024 xmlSchemaComplexType.IsAbstract = mapping.TypeDesc.IsAbstract;
1025 bool openModel = mapping.IsOpenModel;
1026 if (mapping.BaseMapping != null && mapping.BaseMapping.IncludeInSchema)
1027 {
1028 if (mapping.BaseMapping.IsAnonymousType)
1029 {
1030 throw new InvalidOperationException(System.SR.Format(System.SR.XmlAnonymousBaseType, mapping.TypeDesc.Name, mapping.BaseMapping.TypeDesc.Name, "AnonymousType", "false"));
1031 }
1032 if (mapping.HasSimpleContent)
1033 {
1039 }
1040 else
1041 {
1048 }
1049 openModel = false;
1050 }
1051 ExportTypeMembers(xmlSchemaComplexType, mapping.Members, mapping.TypeName, mapping.Namespace, mapping.HasSimpleContent, openModel);
1053 if (mapping.XmlnsMember != null)
1054 {
1056 }
1057 }
1058 else
1059 {
1060 AddSchemaImport(mapping.Namespace, ns);
1061 }
1062 if (mapping.IsAnonymousType)
1063 {
1064 _references[mapping] = null;
1065 if (element != null)
1066 {
1068 }
1069 return XmlQualifiedName.Empty;
1070 }
1072 if (element != null)
1073 {
1075 }
1076 return xmlQualifiedName;
1077 }
1078
1080 {
1082 TypeMapping typeMapping = null;
1084 {
1085 if (memberMapping.Ignore)
1086 {
1087 continue;
1088 }
1089 if (memberMapping.Text != null)
1090 {
1091 if (typeMapping != null)
1092 {
1094 }
1095 typeMapping = memberMapping.Text.Mapping;
1096 }
1097 if (memberMapping.Elements.Length != 0)
1098 {
1100 bool valueTypeOptional = memberMapping.CheckSpecified != 0 || memberMapping.CheckShouldPersist;
1102 }
1103 }
1104 if (xmlSchemaGroupBase.Items.Count > 0)
1105 {
1106 if (type.ContentModel != null)
1107 {
1108 if (type.ContentModel.Content is XmlSchemaComplexContentRestriction)
1109 {
1110 ((XmlSchemaComplexContentRestriction)type.ContentModel.Content).Particle = xmlSchemaGroupBase;
1111 }
1112 else
1113 {
1114 if (!(type.ContentModel.Content is XmlSchemaComplexContentExtension))
1115 {
1116 throw new InvalidOperationException(System.SR.Format(System.SR.XmlInvalidContent, type.ContentModel.Content.GetType().Name));
1117 }
1118 ((XmlSchemaComplexContentExtension)type.ContentModel.Content).Particle = xmlSchemaGroupBase;
1119 }
1120 }
1121 else
1122 {
1124 }
1125 }
1126 if (typeMapping != null)
1127 {
1128 if (hasSimpleContent)
1129 {
1130 if (typeMapping is PrimitiveMapping && xmlSchemaGroupBase.Items.Count == 0)
1131 {
1133 if (primitiveMapping.IsList)
1134 {
1135 type.IsMixed = true;
1136 }
1137 else
1138 {
1139 if (primitiveMapping.IsAnonymousType)
1140 {
1141 throw new InvalidOperationException(System.SR.Format(System.SR.XmlAnonymousBaseType, typeMapping.TypeDesc.Name, primitiveMapping.TypeDesc.Name, "AnonymousType", "false"));
1142 }
1147 }
1148 }
1149 }
1150 else
1151 {
1152 type.IsMixed = true;
1153 }
1154 }
1155 bool flag = false;
1156 for (int j = 0; j < members.Length; j++)
1157 {
1158 AttributeAccessor attribute = members[j].Attribute;
1159 if (attribute != null)
1160 {
1161 ExportAttributeAccessor(type, members[j].Attribute, members[j].CheckSpecified != 0 || members[j].CheckShouldPersist, ns);
1162 if (members[j].Attribute.Any)
1163 {
1164 flag = true;
1165 }
1166 }
1167 }
1168 if (openModel && !flag)
1169 {
1171 attributeAccessor.Any = true;
1173 }
1174 }
1175
1177 {
1178 if (mapping.IsAnonymousType)
1179 {
1180 return;
1181 }
1183 {
1184 if (structMapping.IncludeInSchema)
1185 {
1187 }
1188 }
1189 }
1190
1192 {
1193 if (!mapping.IncludeInSchema)
1194 {
1196 }
1198 if (xmlSchemaSimpleType == null)
1199 {
1203 if (!mapping.IsAnonymousType)
1204 {
1207 }
1209 xmlSchemaSimpleTypeRestriction.BaseTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
1210 for (int i = 0; i < mapping.Constants.Length; i++)
1211 {
1216 }
1217 if (!mapping.IsFlags)
1218 {
1220 }
1221 else
1222 {
1228 }
1229 }
1230 if (!mapping.IsAnonymousType)
1231 {
1232 AddSchemaImport(mapping.Namespace, ns);
1233 }
1234 return xmlSchemaSimpleType;
1235 }
1236
1251}
virtual void Add(object key, object? value)
Definition Hashtable.cs:676
static readonly DBNull Value
Definition DBNull.cs:8
static CultureInfo InvariantCulture
object? Invoke(object? obj, object?[]? parameters)
static string XmlIllegalForm
Definition SR.cs:1428
static string XmlDuplicateTypeName
Definition SR.cs:1406
static string XmlInvalidContent
Definition SR.cs:1600
static string XmlAnonymousBaseType
Definition SR.cs:1616
static string XmlIllegalArrayElement
Definition SR.cs:1426
static string XmlIllegalWildcard
Definition SR.cs:1424
static string XmlInternalError
Definition SR.cs:1812
static string XmlCircularReference2
Definition SR.cs:1614
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlMappingsScopeMismatch
Definition SR.cs:1562
static string XmlDuplicateNamespace
Definition SR.cs:1480
static string XmlInvalidDefaultValue
Definition SR.cs:1520
static string XmlInternalErrorDetails
Definition SR.cs:1814
static string XmlIllegalMultipleText
Definition SR.cs:1670
static string XmlCannotIncludeInSchema
Definition SR.cs:1580
static string XmlBareTextMember
Definition SR.cs:1430
static string XmlBareAttributeMember
Definition SR.cs:1432
Definition SR.cs:7
override XmlSchemaObjectCollection Items
XmlSchemaObjectCollection Items
Definition XmlSchema.cs:174
static string FromEnum(long val, string[] vals, long[] ids, string typeName)
static string FromDefaultValue(object value, string formatter)
static long ToEnum(string val, Hashtable vals, string typeName, bool validate)
XmlSchemaElement ExportElement(ElementAccessor accessor)
void ExportElementAccessor(XmlSchemaGroupBase group, ElementAccessor accessor, bool repeats, bool valueTypeOptional, string ns)
void ExportDerivedMappings(StructMapping mapping)
static bool NamespacesEqual(string ns1, string ns2)
void ExportTypeMapping(XmlTypeMapping xmlTypeMapping)
void AddXmlnsAnnotation(XmlSchemaComplexType type, string xmlnsMemberName)
static bool IsAnyType(XmlSchemaType schemaType, bool mixed, bool unbounded)
void ExportMembersMapping(XmlMembersMapping xmlMembersMapping)
void ExportMembersMapping(XmlMembersMapping xmlMembersMapping, bool exportEnclosingType)
void AddSchemaImport(string ns, string referencingNs)
void ExportMapping(Mapping mapping, string ns, bool isAny)
XmlSchemaType ExportAnonymousPrimitiveMapping(PrimitiveMapping mapping)
static string ExportDefaultValue(TypeMapping mapping, object value)
static XmlSchemaType FindSchemaType(string name, XmlSchemaObjectCollection items)
void AddSchemaItem(XmlSchemaObject item, string ns, string referencingNs)
void CheckForDuplicateType(TypeMapping mapping, string newNamespace)
XmlSchema AddSchema(string targetNamespace)
XmlQualifiedName ExportNonXsdPrimitiveMapping(PrimitiveMapping mapping, string ns)
XmlSchemaType ExportSpecialMapping(SpecialMapping mapping, string ns, bool isAny, XmlSchemaElement element)
XmlSchemaType ExportMembersMapping(MembersMapping mapping, string ns)
XmlQualifiedName? ExportTypeMapping(XmlMembersMapping xmlMembersMapping)
bool SchemaContainsItem(XmlSchemaObject item, string ns)
void ExportArrayMapping(ArrayMapping mapping, string ns, XmlSchemaElement element)
void ExportAttributeAccessor(XmlSchemaComplexType type, AttributeAccessor accessor, bool valueTypeOptional, string ns)
XmlQualifiedName ExportPrimitiveMapping(PrimitiveMapping mapping, string ns)
XmlQualifiedName ExportStructMapping(StructMapping mapping, string ns, XmlSchemaElement element)
void ExportTypeMembers(XmlSchemaComplexType type, MemberMapping[] members, string name, string ns, bool hasSimpleContent, bool openModel)
XmlSchemaType ExportEnumMapping(EnumMapping mapping, string ns)
void ExportElementAccessors(XmlSchemaGroupBase group, ElementAccessor[] accessors, bool repeats, bool valueTypeOptional, string ns)
string? ExportAnyType(XmlMembersMapping members)
XmlSchemaImport FindImport(XmlSchema schema, string ns)
void ExportElementMapping(XmlSchemaElement element, Mapping mapping, string ns, bool isAny)
static bool IsMixed(XmlSchemaType type)
bool Contains(XmlSchema schema)
int Add(XmlSchema schema, bool delay)
virtual ? XmlNode InsertBefore(XmlNode newChild, XmlNode? refChild)
Definition XmlNode.cs:445
static readonly XmlQualifiedName Empty