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)

지정한 계약 생성기, 계약 설명 및 계약 코드 형식 선언을 사용하여 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)

적용 대상