OperationContractGenerationContext 類別

定義

傳遞至 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 自訂實作 (用來在服務或作業層級匯入自訂 WSDL 項目或修改程式碼) 上實作 System.ServiceModel.Description.IWsdlImportExtension 介面。 若要在服務層級修改程式碼,請參閱 System.ServiceModel.Description.IServiceContractGenerationExtension

建構函式

OperationContractGenerationContext(ServiceContractGenerator, ServiceContractGenerationContext, OperationDescription, CodeTypeDeclaration, CodeMemberMethod)

使用指定的合約產生器、合約內容、作業描述、程式碼型別宣告、同步處理方法和工作方法,初始化 OperationContractGenerationContext 類別的新執行個體。

OperationContractGenerationContext(ServiceContractGenerator, ServiceContractGenerationContext, OperationDescription, CodeTypeDeclaration, CodeMemberMethod, CodeMemberMethod)

使用指定的合約產生器、合約內容、作業描述、程式碼型別宣告和方法,初始化 OperationContractGenerationContext 類別的新執行個體。

OperationContractGenerationContext(ServiceContractGenerator, ServiceContractGenerationContext, OperationDescription, CodeTypeDeclaration, CodeMemberMethod, CodeMemberMethod, CodeMemberMethod)

初始化 OperationContractGenerationContext 類別的新執行個體。

OperationContractGenerationContext(ServiceContractGenerator, ServiceContractGenerationContext, OperationDescription, CodeTypeDeclaration, CodeMemberMethod, CodeMemberMethod, CodeMemberMethod, CodeMemberMethod)

使用指定的合約產生器、合約內容、作業描述、程式碼型別宣告、同步處理方法、開始方法、結束方法和工作方法,初始化 OperationContractGenerationContext 類別的新執行個體。

屬性

BeginMethod

取得非同步開始作業的 CodeMemberMethod

Contract

取得服務合約的程式碼產生內容。

DeclaringType

取得目前作業的宣告型別。

EndMethod

取得非同步結束作業宣告。

IsAsync

取得值,這個值會指出是否產生目前作業的非同步方法。

IsTask

取得值,指出是否針對目前作業產生工作。

Operation

取得目前作業的 OperationDescription

ServiceContractGenerator

取得產生目前作業的 ServiceContractGenerator

SyncMethod

取得同步作業的 CodeMemberMethod

TaskMethod

取得工作作業的 CodeMemberMethod

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於