Export (0) Print
Expand All

IServiceContractGenerationExtension.GenerateContract Method

Implement to modify the code document object model prior to the contract generation process.

Namespace: System.ServiceModel.Description
Assembly: System.ServiceModel (in system.servicemodel.dll)

void GenerateContract (
	ServiceContractGenerationContext^ context
)
void GenerateContract (
	ServiceContractGenerationContext context
)
function GenerateContract (
	context : ServiceContractGenerationContext
)
Not applicable.

Parameters

context

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.

No code example is currently available or this language may not be supported.

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.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft