ServiceContractGenerationContext クラス

定義

GenerateContract(ServiceContractGenerationContext) メソッドに渡され、コードの生成前にサービス コントラクトとそのコンテキストを変更できるようにします。

public ref class ServiceContractGenerationContext
public class ServiceContractGenerationContext
type ServiceContractGenerationContext = class
Public Class ServiceContractGenerationContext
継承
ServiceContractGenerationContext

ServiceContractGenerationContext メソッドに渡される IServiceContractGenerationExtension.GenerateContract オブジェクトを使用して、カスタム WSDL 要素から抽出したコード コメントを追加する方法を次の例に示します。

public void GenerateContract(ServiceContractGenerationContext context)
{
  Console.WriteLine("In generate contract.");
  context.ContractType.Comments.AddRange(Formatter.FormatComments(commentText));
}

追加されるコード コメントのコード例を次に示します。

/// 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

注釈

ServiceContractGenerationContext メソッドに渡される IServiceContractGenerationExtension.GenerateContract オブジェクトを使用して、コードの生成前に Code Document Object Model を変更できます。 通常、System.ServiceModel.Description.IServiceContractGenerationExtension インターフェイスは、System.ServiceModel.Description.IWsdlImportExtension のカスタム実装に実装されます。このカスタム実装は、カスタム WSDL 要素をインポート、または他の方法によってサービス レベルまたは操作レベルでコードを変更するために使用されます。 操作レベルでコードを変更する方法については、System.ServiceModel.Description.IOperationContractGenerationExtension を参照してください。

コンストラクター

ServiceContractGenerationContext(ServiceContractGenerator, ContractDescription, CodeTypeDeclaration)

指定したコントラクト ジェネレーター、コントラクトの説明、およびコントラクト コード型宣言を使用して、ServiceContractGenerationContext クラスの新しいインスタンスを初期化します。

ServiceContractGenerationContext(ServiceContractGenerator, ContractDescription, CodeTypeDeclaration, CodeTypeDeclaration)

指定したコントラクト ジェネレーター、コントラクトの説明、およびコントラクト コード型宣言を使用して、ServiceContractGenerationContext クラスの新しいインスタンスを初期化します。

プロパティ

Contract

現在のコントラクトの ContractDescription を取得します。

ContractType

現在のコントラクトの CodeTypeDeclaration を取得します。

DuplexCallbackType

サービス コントラクト上の双方向コールバック コントラクトの CodeTypeDeclaration を取得します。

Operations

コントラクトの操作を表す OperationContractGenerationContext オブジェクトのコレクションを取得します。

ServiceContractGenerator

コントラクトを生成する ServiceContractGenerator を取得します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象