OperationContractGenerationContext 类

定义

传递给 GenerateOperation(OperationContractGenerationContext) 方法可以在生成代码之前修改操作协定及其上下文。Passed to the GenerateOperation(OperationContractGenerationContext) method to enable the modification of an operation contract and its context prior to generating code.

public ref class OperationContractGenerationContext
public class OperationContractGenerationContext
type OperationContractGenerationContext = class
Public Class OperationContractGenerationContext
继承
OperationContractGenerationContext

示例

下面的示例演示了如何使用传递给 OperationContractGenerationContext 方法的 IOperationContractGenerationExtension.GenerateOperation 对象,来添加从自定义 WSDL 元素提取的代码注释。The following example shows the use of the OperationContractGenerationContext object passed to the IOperationContractGenerationExtension.GenerateOperation method to add code comments extracted from custom WSDL elements.

public void GenerateOperation(OperationContractGenerationContext context)
{
  context.SyncMethod.Comments.AddRange(Formatter.FormatComments(commentText));
  Console.WriteLine("In generate operation.");
}

下面的代码示例给出了所生成的代码注释。The following code example shows the resulting code comments.

/// 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 对象可以在生成代码之前修改代码文档对象模型。Use the OperationContractGenerationContext object passed to the IOperationContractGenerationExtension.GenerateOperation method to modify the code document object model prior to the generation of code. 通常,System.ServiceModel.Description.IOperationContractGenerationExtension 接口是在自定义 System.ServiceModel.Description.IWsdlImportExtension 实现上实现的,该实现可用于导入自定义 WSDL 元素,或者在服务或操作级别修改代码。Typically, the System.ServiceModel.Description.IOperationContractGenerationExtension interface is implemented on a custom System.ServiceModel.Description.IWsdlImportExtension implementation that is used to import custom WSDL elements or otherwise modify the code at the service or operation level. 若要在服务级别修改代码,请参见 System.ServiceModel.Description.IServiceContractGenerationExtensionTo modify the code at the service level, see System.ServiceModel.Description.IServiceContractGenerationExtension.

构造函数

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

使用指定的协定生成器、协定上下文、操作说明、代码类型声明、同步方法和任务方法初始化 OperationContractGenerationContext 类的新实例。Initializes a new instance of the OperationContractGenerationContext class using the specified contract generator, contract context, operation description, code type declaration, synchronization method and task method.

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

使用指定的协定生成器、协定上下文、操作说明、代码类型声明和方法初始化 OperationContractGenerationContext 类的新实例。Initializes a new instance of the OperationContractGenerationContext class using the specified contract generator, contract context, operation description, code type declaration, and method.

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

初始化 OperationContractGenerationContext 类的新实例。Initializes a new instance of the OperationContractGenerationContext class.

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

使用指定的协定生成器、协定上下文、操作说明、代码类型声明、同步方法、开始方法和方法初始化 OperationContractGenerationContext 类的新实例。Initializes a new instance of the OperationContractGenerationContext class using the specified contract generator, contract context, operation description, code type declaration, synchronization method, begin method, end method, and task method.

属性

BeginMethod

获取异步开始操作的 CodeMemberMethodGets the CodeMemberMethod for the asynchronous begin operation.

Contract

获取服务协定的代码生成上下文。Gets the code generation context for the service contract.

DeclaringType

获取当前操作的声明类型。Gets the declaring type for the current operation.

EndMethod

获取异步结束操作声明。Gets the asynchronous end operation declaration.

IsAsync

获取指示是否为当前操作生成异步方法的值。Gets a value that indicates whether asynchronous methods are generated for the current operation.

IsTask

获取一个值,该值指示是否为当前操作生成一个任务。Gets a value that indicates whether a task is generated for the current operation.

Operation

获取当前操作的 OperationDescriptionGets the OperationDescription for the current operation.

ServiceContractGenerator

获取生成当前操作的 ServiceContractGeneratorGets the ServiceContractGenerator that generates the current operation.

SyncMethod

获取同步操作的 CodeMemberMethodGets the CodeMemberMethod for the synchronous operation.

TaskMethod

获取任务操作的 CodeMemberMethodGets the CodeMemberMethod for the task operation.

方法

Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于