private void CodePortType(WsdlPortType portType, string directory, string namespaceName) { using (var file = new CodeFile(directory, $"{portType.CodeName}.cs")) { file.WriteLine("using System.Collections.Generic;"); file.WriteLine("using System.Threading.Tasks;"); file.WriteLine(""); using (var nsScope = file.CreateNamespaceScope(namespaceName)) { file.Comment(portType.Documentation); file.WriteLine($"public interface {portType.CodeName}"); file.Ocb(); foreach (var op in portType.Operations) { var outputType = GetPropertyTypeCode(op.OutputElement.Properties[0], true); string inputs = null; if (op.InputElement.Properties.Count > 0) { string inputParamName = EscapeKeyword(StringUtil.ToCamelCaseName(op.InputElement.Properties[0].CodeName)); inputs = GetPropertyTypeCode(op.InputElement.Properties[0], true) + " " + inputParamName; } file.Comment(op.Documentation); file.WriteLine($"Task<{outputType}> {op.CodeName}Async({inputs});"); } file.Ccb(); } } }
private WsdlPortType CreatePortType(ServiceDescription wsdl, PortType portType) { var pt = new WsdlPortType(); pt.Wsdl = wsdl; pt.XName = new XmlQualifiedName(portType.Name, portType.ServiceDescription.TargetNamespace); pt.Documentation = GetDocumentation(portType.Documentation); foreach (Operation operation in portType.Operations) { var ptOpr = new WsdlPortTypeOperation(); pt.Operations.Add(ptOpr); ptOpr.Name = operation.Name; ptOpr.Documentation = GetDocumentation(operation.Documentation); foreach (OperationMessage msg in operation.Messages) { var elementName = wsdl.Messages[msg.Name].Parts[0].Element; if (msg is OperationInput) { ptOpr.InputElement = new WsdlType { XName = elementName }; } else if (msg is OperationOutput) { ptOpr.OutputElement = new WsdlType { XName = elementName }; } } foreach (OperationFault msg in operation.Faults) { var elementName = wsdl.Messages[msg.Name].Parts[0].Element; ptOpr.FaultElement = new WsdlType { XName = elementName }; } } return(pt); }