OperationContractGenerationContext Klass
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Skickades till GenerateOperation(OperationContractGenerationContext) metoden för att aktivera ändring av ett åtgärdskontrakt och dess kontext innan kod genererades.
public ref class OperationContractGenerationContext
public class OperationContractGenerationContext
type OperationContractGenerationContext = class
Public Class OperationContractGenerationContext
- Arv
-
OperationContractGenerationContext
Exempel
I följande exempel visas hur OperationContractGenerationContext objektet som skickas till IOperationContractGenerationExtension.GenerateOperation metoden används för att lägga till kodkommenter som extraherats från anpassade WSDL-element.
public void GenerateOperation(OperationContractGenerationContext context)
{
context.SyncMethod.Comments.AddRange(Formatter.FormatComments(commentText));
Console.WriteLine("In generate operation.");
}
I följande kodexempel visas de resulterande kodkommentarna.
/// 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
Kommentarer
Använd objektet som OperationContractGenerationContext skickades till IOperationContractGenerationExtension.GenerateOperation metoden för att ändra koddokumentets objektmodell innan kodgenereringen. System.ServiceModel.Description.IOperationContractGenerationExtension Vanligtvis implementeras gränssnittet på en anpassad System.ServiceModel.Description.IWsdlImportExtension implementering som används för att importera anpassade WSDL-element eller på annat sätt ändra koden på tjänst- eller åtgärdsnivå. Information om hur du ändrar koden på tjänstnivå finns System.ServiceModel.Description.IServiceContractGenerationExtensioni .
Konstruktorer
Egenskaper
| Name | Description |
|---|---|
| BeginMethod |
CodeMemberMethod Hämtar för den asynkrona startåtgärden. |
| Contract |
Hämtar kodgenereringskontexten för tjänstkontraktet. |
| DeclaringType |
Hämtar deklareringstypen för den aktuella åtgärden. |
| EndMethod |
Hämtar den asynkrona slutåtgärdsdeklarationen. |
| IsAsync |
Hämtar ett värde som anger om asynkrona metoder genereras för den aktuella åtgärden. |
| IsTask |
Hämtar ett värde som anger om en aktivitet genereras för den aktuella åtgärden. |
| Operation |
OperationDescription Hämtar för den aktuella åtgärden. |
| ServiceContractGenerator |
Hämtar den ServiceContractGenerator som genererar den aktuella åtgärden. |
| SyncMethod |
CodeMemberMethod Hämtar för synkron åtgärd. |
| TaskMethod |
CodeMemberMethod Hämtar för aktivitetsåtgärden. |
Metoder
| Name | Description |
|---|---|
| Equals(Object) |
Avgör om det angivna objektet är lika med det aktuella objektet. (Ärvd från Object) |
| GetHashCode() |
Fungerar som standard-hash-funktion. (Ärvd från Object) |
| GetType() |
Hämtar den aktuella instansen Type . (Ärvd från Object) |
| MemberwiseClone() |
Skapar en ytlig kopia av den aktuella Object. (Ärvd från Object) |
| ToString() |
Returnerar en sträng som representerar det aktuella objektet. (Ärvd från Object) |