我正在使用类ServiceContractGenerator在应用程序上“重新托管”VisualStudio的Add-ServiceReference函数。
它完美无缺,但我找不到在ServiceContractGenerator中设置以下选项的位置:
VisualStudio Add-ServiceReferenceOptions
实际上现在它将集合映射到数组,因为它是默认选择,我想让用户在VS之间选择选项。
代码段:
Private Shared Function ImportWCFServiceReferenceDescription(url As String, Code As String, assemblyVersion As String) As ImportResult
Dim result As ImportResult = New ImportResult() With {.Imported = False, .ErrorMessage = New StringBuilder(), .CompileUnit = New CodeCompileUnit()}
If Not url.ToLower.EndsWith("?wsdl") AndAlso Not url.ToLower.EndsWith("?singlewsdl") Then url = url & "?wsdl"
Dim mexClient As New MetadataExchangeClient(New Uri(url), MetadataExchangeClientMode.HttpGet)
mexClient.ResolveMetadataReferences = True
Dim metaDocs = mexClient.GetMetadata()
Dim importer As New WsdlImporter(metaDocs)
Dim generator As New ServiceContractGenerator()
generator.NamespaceMappings.Add("*", String.Format("{0}.{1}", RootNamespace, Code))
Dim contracts = importer.ImportAllContracts()
importer.ImportAllEndpoints()
For Each contract As ContractDescription In contracts
generator.GenerateServiceContractType(contract)
Next
If generator.Errors.Count <> 0 Then
result.ErrorMessage.AppendLine("No code generated")
Return result
End If
result.CompileUnit = generator.TargetCompileUnit
result.Imported = True
Return result
End Function
由于
FT