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 オブジェクトを使用します。 通常、 System.ServiceModel.Description.IServiceContractGenerationExtension インターフェイスは、カスタム WSDL 要素をインポートしたり、サービスレベルまたは操作レベルでコードを変更したりするために使用されるカスタム System.ServiceModel.Description.IWsdlImportExtension 実装に実装されます。 操作レベルでコードを変更するには、 System.ServiceModel.Description.IOperationContractGenerationExtensionを参照してください。

コンストラクター

名前 説明
ServiceContractGenerationContext(ServiceContractGenerator, ContractDescription, CodeTypeDeclaration, CodeTypeDeclaration)

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

ServiceContractGenerationContext(ServiceContractGenerator, ContractDescription, 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)

適用対象