OperationContractGenerationContext Klasse
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Wird an die GenerateOperation(OperationContractGenerationContext) Methode übergeben, um die Änderung eines Vorgangsvertrags und seines Kontexts vor dem Generieren von Code zu aktivieren.
public ref class OperationContractGenerationContext
public class OperationContractGenerationContext
type OperationContractGenerationContext = class
Public Class OperationContractGenerationContext
- Vererbung
-
OperationContractGenerationContext
Beispiele
Das folgende Beispiel zeigt die Verwendung des Objekts, das OperationContractGenerationContext an die Methode übergeben wird, um Codekommentare hinzuzufügen, die IOperationContractGenerationExtension.GenerateOperation aus benutzerdefinierten WSDL-Elementen extrahiert wurden.
public void GenerateOperation(OperationContractGenerationContext context)
{
context.SyncMethod.Comments.AddRange(Formatter.FormatComments(commentText));
Console.WriteLine("In generate operation.");
}
Das folgende Codebeispiel zeigt die resultierenden Codekommentare.
/// 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
Hinweise
Verwenden Sie das OperationContractGenerationContext an die IOperationContractGenerationExtension.GenerateOperation Methode übergebene Objekt, um das Codedokumentobjektmodell vor der Generierung von Code zu ändern. In der Regel wird die System.ServiceModel.Description.IOperationContractGenerationExtension Schnittstelle in einer benutzerdefinierten Implementierung implementiert, die verwendet wird, um benutzerdefinierte System.ServiceModel.Description.IWsdlImportExtension WSDL-Elemente zu importieren oder den Code auf Dienst- oder Vorgangsebene anderweitig zu ändern. Informationen zum Ändern des Codes auf Dienstebene finden Sie unter System.ServiceModel.Description.IServiceContractGenerationExtension.
Konstruktoren
Eigenschaften
| Name | Beschreibung |
|---|---|
| BeginMethod |
Ruft den CodeMemberMethod asynchronen Anfangsvorgang ab. |
| Contract |
Ruft den Codegenerierungskontext für den Dienstvertrag ab. |
| DeclaringType |
Ruft den deklarierenden Typ für den aktuellen Vorgang ab. |
| EndMethod |
Ruft die asynchrone Endvorgangsdeklaration ab. |
| IsAsync |
Ruft einen Wert ab, der angibt, ob asynchrone Methoden für den aktuellen Vorgang generiert werden. |
| IsTask |
Ruft einen Wert ab, der angibt, ob eine Aufgabe für den aktuellen Vorgang generiert wird. |
| Operation |
Ruft den OperationDescription aktuellen Vorgang ab. |
| ServiceContractGenerator |
Ruft ab, die den ServiceContractGenerator aktuellen Vorgang generiert. |
| SyncMethod |
Ruft den CodeMemberMethod synchronen Vorgang ab. |
| TaskMethod |
Ruft den CodeMemberMethod Vorgangsvorgang ab. |
Methoden
| Name | Beschreibung |
|---|---|
| Equals(Object) |
Bestimmt, ob das angegebene Objekt dem aktuellen Objekt entspricht. (Geerbt von Object) |
| GetHashCode() |
Dient als Standardhashfunktion. (Geerbt von Object) |
| GetType() |
Ruft die Type der aktuellen Instanz ab. (Geerbt von Object) |
| MemberwiseClone() |
Erstellt eine flache Kopie der aktuellen Object. (Geerbt von Object) |
| ToString() |
Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt. (Geerbt von Object) |