void ExportRoot(StructMapping mapping) { if (!rootExported) { rootExported = true; ExportDerivedStructs(mapping); for (StructMapping derived = mapping.DerivedMappings; derived != null; derived = derived.NextDerivedMapping) { if (!derived.ReferencedByElement) { CodeIdentifier.CheckValidTypeIdentifier(derived.TypeDesc.FullName); CodeAttributeArgument[] arguments = new CodeAttributeArgument[] { new CodeAttributeArgument(new CodeTypeOfExpression(derived.TypeDesc.FullName)) }; AddCustomAttribute(includeMetadata, typeof(XmlIncludeAttribute), arguments); } } Hashtable typesIncluded = new Hashtable(); foreach (TypeMapping m in scope.TypeMappings) { if (m is ArrayMapping) { ArrayMapping arrayMapping = (ArrayMapping)m; if (ShouldInclude(arrayMapping) && !typesIncluded.Contains(arrayMapping.TypeDesc.FullName)) { CodeIdentifier.CheckValidTypeIdentifier(arrayMapping.TypeDesc.FullName); CodeAttributeArgument[] arguments = new CodeAttributeArgument[] { new CodeAttributeArgument(new CodeTypeOfExpression(arrayMapping.TypeDesc.FullName)) }; AddCustomAttribute(includeMetadata, typeof(XmlIncludeAttribute), arguments); typesIncluded.Add(arrayMapping.TypeDesc.FullName, ""); } } } } }
void AddIncludeMetadata(CodeAttributeDeclarationCollection metadata, StructMapping mapping) { for (StructMapping derived = mapping.DerivedMappings; derived != null; derived = derived.NextDerivedMapping) { CodeIdentifier.CheckValidTypeIdentifier(derived.TypeDesc.FullName); CodeAttributeArgument[] arguments = new CodeAttributeArgument[] { new CodeAttributeArgument(new CodeTypeOfExpression(derived.TypeDesc.FullName)) }; AddCustomAttribute(metadata, typeof(XmlIncludeAttribute), arguments); AddIncludeMetadata(metadata, derived); } }
void ExportText(CodeAttributeDeclarationCollection metadata, TypeDesc typeDesc, string dataType) { CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(XmlTextAttribute).FullName); if (typeDesc != null) { CodeIdentifier.CheckValidTypeIdentifier(typeDesc.FullName); attribute.Arguments.Add(new CodeAttributeArgument(new CodeTypeOfExpression(typeDesc.FullName))); } if (dataType != null) { attribute.Arguments.Add(new CodeAttributeArgument("DataType", new CodePrimitiveExpression(dataType))); } metadata.Add(attribute); }
void ExportRoot(StructMapping mapping) { if (!rootExported) { rootExported = true; ExportDerivedStructs(mapping); for (StructMapping derived = mapping.DerivedMappings; derived != null; derived = derived.NextDerivedMapping) { if (!derived.ReferencedByElement) { CodeIdentifier.CheckValidTypeIdentifier(derived.TypeDesc.FullName); CodeAttributeArgument[] arguments = new CodeAttributeArgument[] { new CodeAttributeArgument(new CodeTypeOfExpression(derived.TypeDesc.FullName)) }; AddCustomAttribute(includeMetadata, typeof(SoapIncludeAttribute), arguments); } } } }
void ExportMetadata(CodeAttributeDeclarationCollection metadata, Type attributeType, string name, string ns, TypeDesc typeDesc, TypeDesc dataTypeDesc, object isNullable, XmlSchemaForm form, int nestingLevel) { CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(attributeType.FullName); if (name != null) { attribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(name))); } if (typeDesc != null) { CodeIdentifier.CheckValidTypeIdentifier(typeDesc.FullName); attribute.Arguments.Add(new CodeAttributeArgument(new CodeTypeOfExpression(typeDesc.FullName))); } if (form != XmlSchemaForm.None) { attribute.Arguments.Add(new CodeAttributeArgument("Form", new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(typeof(XmlSchemaForm).FullName), Enum.Format(typeof(XmlSchemaForm), form, "G")))); } if (ns != null) { attribute.Arguments.Add(new CodeAttributeArgument("Namespace", new CodePrimitiveExpression(ns))); } if (dataTypeDesc != null && dataTypeDesc.IsAmbiguousDataType) { attribute.Arguments.Add(new CodeAttributeArgument("DataType", new CodePrimitiveExpression(dataTypeDesc.DataType.Name))); } if (isNullable != null) { attribute.Arguments.Add(new CodeAttributeArgument("IsNullable", new CodePrimitiveExpression((bool)isNullable))); } if (nestingLevel > 0) { attribute.Arguments.Add(new CodeAttributeArgument("NestingLevel", new CodePrimitiveExpression(nestingLevel))); } if (attribute.Arguments.Count == 0 && attributeType == typeof(XmlElementAttribute)) { return; } metadata.Add(attribute); }