ServiceContractGenerationContext.ContractType Propriété
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.
Obtient la CodeTypeDeclaration du contrat actuel.
public:
property System::CodeDom::CodeTypeDeclaration ^ ContractType { System::CodeDom::CodeTypeDeclaration ^ get(); };
public System.CodeDom.CodeTypeDeclaration ContractType { get; }
member this.ContractType : System.CodeDom.CodeTypeDeclaration
Public ReadOnly Property ContractType As CodeTypeDeclaration
Valeur de propriété
CodeTypeDeclaration du contrat actuel.
Exemples
L'exemple suivant illustre l'objet ServiceContractGenerationContext passé à la méthode IServiceContractGenerationExtension.GenerateContract pour ajouter des commentaires de code extraits d'éléments WSDL personnalisés.
public void GenerateContract(ServiceContractGenerationContext context)
{
Console.WriteLine("In generate contract.");
context.ContractType.Comments.AddRange(Formatter.FormatComments(commentText));
}
L'exemple de code suivant montre les commentaires de code obtenus.
/// 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 la propriété ContractType pour examiner ou modifier la System.CodeDom.CodeTypeDeclaration du contrat actuel avant que le code ne soit généré.