OperationContractGenerationContext Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Passé à la GenerateOperation(OperationContractGenerationContext) méthode pour activer la modification d’un contrat d’opération et son contexte avant de générer du code.
public ref class OperationContractGenerationContext
public class OperationContractGenerationContext
type OperationContractGenerationContext = class
Public Class OperationContractGenerationContext
- Héritage
-
OperationContractGenerationContext
Exemples
L’exemple suivant montre l’utilisation de l’objet OperationContractGenerationContext passé à la IOperationContractGenerationExtension.GenerateOperation méthode pour ajouter des commentaires de code extraits d’éléments WSDL personnalisés.
public void GenerateOperation(OperationContractGenerationContext context)
{
context.SyncMethod.Comments.AddRange(Formatter.FormatComments(commentText));
Console.WriteLine("In generate operation.");
}
L’exemple de code suivant montre les commentaires de code résultants.
/// 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
Remarques
Utilisez l’objet OperationContractGenerationContext transmis à la IOperationContractGenerationExtension.GenerateOperation méthode pour modifier le modèle objet de document de code avant la génération du code. En règle générale, l’interface System.ServiceModel.Description.IOperationContractGenerationExtension est implémentée sur une implémentation personnalisée System.ServiceModel.Description.IWsdlImportExtension utilisée pour importer des éléments WSDL personnalisés ou modifier le code au niveau du service ou de l’opération. Pour modifier le code au niveau du service, consultez System.ServiceModel.Description.IServiceContractGenerationExtension.
Constructeurs
Propriétés
| Nom | Description |
|---|---|
| BeginMethod |
Obtient l’opération CodeMemberMethod de début asynchrone. |
| Contract |
Obtient le contexte de génération de code pour le contrat de service. |
| DeclaringType |
Obtient le type de déclaration pour l’opération actuelle. |
| EndMethod |
Obtient la déclaration d’opération de fin asynchrone. |
| IsAsync |
Obtient une valeur qui indique si les méthodes asynchrones sont générées pour l’opération actuelle. |
| IsTask |
Obtient une valeur qui indique si une tâche est générée pour l’opération en cours. |
| Operation |
Obtient l’opération OperationDescription en cours. |
| ServiceContractGenerator |
Obtient l’opération ServiceContractGenerator en cours. |
| SyncMethod |
Obtient l’opération CodeMemberMethod synchrone. |
| TaskMethod |
Obtient l’opération CodeMemberMethod de tâche. |
Méthodes
| Nom | Description |
|---|---|
| Equals(Object) |
Détermine si l’objet spécifié est égal à l’objet actuel. (Hérité de Object) |
| GetHashCode() |
Sert de fonction de hachage par défaut. (Hérité de Object) |
| GetType() |
Obtient la Type de l’instance actuelle. (Hérité de Object) |
| MemberwiseClone() |
Crée une copie superficielle du Objectactuel. (Hérité de Object) |
| ToString() |
Retourne une chaîne qui représente l’objet actuel. (Hérité de Object) |