OperationContractGenerationContext Classe
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Passado ao GenerateOperation(OperationContractGenerationContext) método para permitir a modificação de um contrato de operação e do seu contexto antes de gerar código.
public ref class OperationContractGenerationContext
public class OperationContractGenerationContext
type OperationContractGenerationContext = class
Public Class OperationContractGenerationContext
- Herança
-
OperationContractGenerationContext
Exemplos
O exemplo seguinte mostra a utilização do OperationContractGenerationContext objeto passado ao IOperationContractGenerationExtension.GenerateOperation método para adicionar comentários de código extraídos de elementos WSDL personalizados.
public void GenerateOperation(OperationContractGenerationContext context)
{
context.SyncMethod.Comments.AddRange(Formatter.FormatComments(commentText));
Console.WriteLine("In generate operation.");
}
O seguinte exemplo de código mostra os comentários de código resultantes.
/// From WSDL Documentation:
///
/// <summary>This contract is a stateless contract that provides a mechanism for
/// computing the nth Fibonacci term.</summary>
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://microsoft.wcf.documentation", ConfigurationName="IFibonacci")]
public interface IFibonacci
{
/// From WSDL Documentation:
///
/// <summary>The Compute operation returns the nth Fibonacci number. Because it
/// uses dual recursion it's very inefficient and therefore useful to demonstrate
/// caching.</summary><returns>The nth Fibonacci number.</returns><param
/// name="num">The value to use when computing the Fibonacci number.</param>
///
[System.ServiceModel.OperationContractAttribute(Action="http://microsoft.wcf.documentation/IFibonacci/Compute", ReplyAction="http://microsoft.wcf.documentation/IFibonacci/ComputeResponse")]
int Compute(int num);
/// From WSDL Documentation:
///
/// <summary>The GetPerson operation tests custom WSDL documentation
/// generation.</summary><returns>The Person object to be returned.</returns><param
/// name="FirstParameter">The value for the first parameter.</param><param
/// name="SecondParameter">The value for the second parameter.</param>
///
[System.ServiceModel.OperationContractAttribute(Action="http://microsoft.wcf.documentation/IFibonacci/GetPerson", ReplyAction="http://microsoft.wcf.documentation/IFibonacci/GetPersonResponse")]
Microsoft.WCF.Documentation.Person GetPerson(int FirstParameter, int SecondParameter);
}
'''From WSDL Documentation:
'''
'''<summary>This contract is a stateless contract that provides a mechanism for
'''computing the nth Fibonacci term.</summary>
'''
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0"), _
System.ServiceModel.ServiceContractAttribute([Namespace]:="http://microsoft.wcf.documentation", ConfigurationName:="IFibonacci")> _
Public Interface IFibonacci
'''From WSDL Documentation:
'''
'''<summary>The Compute operation returns the nth Fibonacci number. Because it
'''uses dual recursion it's very inefficient and therefore useful to demonstrate
'''caching.</summary><returns>The nth Fibonacci number.</returns><param
'''name="num">The value to use when computing the Fibonacci number.</param>
'''
<System.ServiceModel.OperationContractAttribute(Action:="http://microsoft.wcf.documentation/IFibonacci/Compute", ReplyAction:="http://microsoft.wcf.documentation/IFibonacci/ComputeResponse")> _
Function Compute(ByVal num As Integer) As Integer
'''From WSDL Documentation:
'''
'''<summary>The GetPerson operation tests custom WSDL documentation
'''generation.</summary><returns>The Person object to be returned.</returns><param
'''name="FirstParameter">The value for the first parameter.</param><param
'''name="SecondParameter">The value for the second parameter.</param>
'''
<System.ServiceModel.OperationContractAttribute(Action:="http://microsoft.wcf.documentation/IFibonacci/GetPerson", ReplyAction:="http://microsoft.wcf.documentation/IFibonacci/GetPersonResponse")> _
Function GetPerson(ByVal FirstParameter As Integer, ByVal SecondParameter As Integer) As Microsoft.WCF.Documentation.Person
End Interface
Observações
Use o OperationContractGenerationContext objeto passado ao IOperationContractGenerationExtension.GenerateOperation método para modificar o modelo de objeto do documento de código antes da geração do código. Normalmente, a System.ServiceModel.Description.IOperationContractGenerationExtension interface é implementada numa implementação personalizada System.ServiceModel.Description.IWsdlImportExtension que é usada para importar elementos WSDL personalizados ou modificar o código ao nível do serviço ou operação. Para modificar o código ao nível do serviço, veja System.ServiceModel.Description.IServiceContractGenerationExtension.
Construtores
Propriedades
| Name | Description |
|---|---|
| BeginMethod |
Obtém-se para CodeMemberMethod a operação assíncrona de início. |
| Contract |
Obtém o contexto de geração de código para o contrato de serviço. |
| DeclaringType |
Obtém o tipo de declaração para a operação atual. |
| EndMethod |
Obtém a declaração de fim de operação assíncrona. |
| IsAsync |
Obtém um valor que indica se métodos assíncronos são gerados para a operação atual. |
| IsTask |
Obtém um valor que indica se uma tarefa é gerada para a operação atual. |
| Operation |
Recebe o OperationDescription para a operação atual. |
| ServiceContractGenerator |
Obtém o ServiceContractGenerator que gera a operação atual. |
| SyncMethod |
Obtém o CodeMemberMethod para a operação síncrona. |
| TaskMethod |
Obtém o CodeMemberMethod resultado da operação de tarefa. |
Métodos
| Name | Description |
|---|---|
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual. (Herdado de Object) |
| GetHashCode() |
Serve como função de hash predefinida. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual. (Herdado de Object) |
| MemberwiseClone() |
Cria uma cópia superficial do atual Object. (Herdado de Object) |
| ToString() |
Devolve uma cadeia que representa o objeto atual. (Herdado de Object) |