OperationContractGenerationContext 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳入 GenerateOperation(OperationContractGenerationContext) 方法,使得在產生程式碼前修改操作合約及其上下文。
public ref class OperationContractGenerationContext
public class OperationContractGenerationContext
type OperationContractGenerationContext = class
Public Class OperationContractGenerationContext
- 繼承
-
OperationContractGenerationContext
範例
以下範例展示了如何利用 OperationContractGenerationContext 傳遞給方法的 IOperationContractGenerationExtension.GenerateOperation 物件,從自訂 WSDL 元素中擷取程式碼註解。
public void GenerateOperation(OperationContractGenerationContext context)
{
context.SyncMethod.Comments.AddRange(Formatter.FormatComments(commentText));
Console.WriteLine("In generate operation.");
}
以下程式碼範例展示了產生的程式碼註解。
/// 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
備註
在產生程式碼前,利用 OperationContractGenerationContext 傳給方法 IOperationContractGenerationExtension.GenerateOperation 的物件來修改程式碼文件物件模型。 通常,該 System.ServiceModel.Description.IOperationContractGenerationExtension 介面是在自訂 System.ServiceModel.Description.IWsdlImportExtension 實作上實作,用於匯入自訂的 WSDL 元素或在服務或操作層級修改程式碼。 若要在服務層級修改程式碼,請參見 System.ServiceModel.Description.IServiceContractGenerationExtension。
建構函式
屬性
| 名稱 | Description |
|---|---|
| BeginMethod |
取得非同步開始操作的 。CodeMemberMethod |
| Contract |
取得服務合約的程式碼產生上下文。 |
| DeclaringType |
取得目前操作的宣告類型。 |
| EndMethod |
取得非同步結束操作宣告。 |
| IsAsync |
會獲得一個值,指示目前操作是否產生非同步方法。 |
| IsTask |
會取得一個值,表示目前操作是否產生了任務。 |
| Operation |
取得 OperationDescription 目前營運的 |
| ServiceContractGenerator |
取得 ServiceContractGenerator 產生當前運算的 。 |
| SyncMethod |
取得 CodeMemberMethod 同步操作的 。 |
| TaskMethod |
為任務操作取得。CodeMemberMethod |
方法
| 名稱 | Description |
|---|---|
| Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
| GetHashCode() |
做為預設哈希函式。 (繼承來源 Object) |
| GetType() |
取得目前實例的 Type。 (繼承來源 Object) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| ToString() |
傳回表示目前 物件的字串。 (繼承來源 Object) |