Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
This topic has not yet been rated - Rate this topic

IOperationContractGenerationExtension.GenerateOperation 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 GenerateOperation (
	OperationContractGenerationContext context
)
void GenerateOperation (
	OperationContractGenerationContext context
)
function GenerateOperation (
	context : OperationContractGenerationContext
)
Not applicable.

Parameters

context

The working context that contains the System.CodeDom types necessary to modify the generated operation.

Typically, a custom System.ServiceModel.Description.IWsdlImportExtension inserts a custom operation behavior into the OperationDescription.Behaviors collection during the call to IWsdlImportExtension.ImportContract or IWsdlImportExtension.ImportEndpoint.

The GenerateOperation method is called once for each contract.

The following code example shows the implementation of the GenerateOperation method that adds a string to the comments section of the operation using the System.CodeDom namespace.

The following code example shows how the operation behavior that implements IOperationContractGenerationExtension is inserted into the OperationDescription.Behaviors collection during the call to IWsdlImportExtension.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));
              }
          }
      }
  }

Finally, the following code example shows the operation generated in both Visual Basic and C#.

/// From WSDL Documentation:
/// 
/// <summary>The string for the Name data member.</summary> 
/// 
[System.Runtime.Serialization.DataMemberAttribute()]
public string Name
{
    get
    {
        return this.NameField;
    }
    set
    {
        this.NameField = value;
    }
}

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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.