IServiceContractGenerationExtension.GenerateContract Method
Assembly: System.ServiceModel (in system.servicemodel.dll)
'Declaration Sub GenerateContract ( _ context As ServiceContractGenerationContext _ ) 'Usage Dim instance As IServiceContractGenerationExtension Dim context As ServiceContractGenerationContext instance.GenerateContract(context)
void GenerateContract ( ServiceContractGenerationContext context )
function GenerateContract (
context : ServiceContractGenerationContext
)
Not applicable.
Parameters
- context
Use the System.ServiceModel.Description.ServiceContractGenerationContext to modify the contract, operations, or the System.ServiceModel.Description.ServiceContractGenerator prior to code generation.
The following code example shows adding an IServiceContractGenerationExtension to the ContractDescription.Behaviors property during the call to ImportContract.
public void ImportContract(WsdlImporter importer, WsdlContractConversionContext context) { Console.Write("ImportContract"); // Contract Documentation if (context.WsdlPortType.Documentation != null) { context.Contract.Behaviors.Add(new WsdlDocumentationImporter(context.WsdlPortType.Documentation)); } // Operation Documentation foreach (Operation operation in context.WsdlPortType.Operations) { if (operation.Documentation != null) { OperationDescription operationDescription = context.Contract.Operations.Find(operation.Name); if (operationDescription != null) { operationDescription.Behaviors.Add(new WsdlDocumentationImporter(operation.Documentation)); } } } }
The following code examples show the implementation of GenerateContract that adds comments to the code generated for a service contract.
public void GenerateContract(ServiceContractGenerationContext context) { Console.WriteLine("In generate contract."); context.ContractType.Comments.AddRange(Formatter.FormatComments(commentText)); }
The following code example shows the generated comments on the service contract.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.