I am running a custom application that imports WSDLs and generates C# source code, using WSDLImporter class to read in contracts.
XSD sequence types are translated into native arrays. What options can I set in order to be able to generate custom collection types?
Schema:
<xs:complexType name="getAllSourcesResponse">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0"
name="return" type="tns:Source"/>
</xs:sequence>
</xs:complexType>
becomes code:
public partial class getAllSourcesResponse
{
[System.Xml.Serialization.XmlElementAttribute("return",
Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public PaymentSource[] @return;
public getAllSourcesResponse()
{
}
public getAllSourcesResponse(Source[] @return)
{
this.@return = @return;
}
}
I looked into SvcUtil.exe code, it appears to do the following, but it does not seem to make any difference in what code my application produces.
WsdlImporter importer = ...
XsdDataContractImporter contractImporter =
new XsdDataContractImporter(codeCompileUnit);
ImportOptions importOptions = new ImportOptions();
importOptions.ReferencedCollectionTypes.Add(
typeof(System.Collections.Generic.IList<>));
contractImporter.Options = importOptions;
importer.State.Add(typeof(XsdDataContractImporter), contractImporter);