OperationContractGenerationContext Класс

Определение

Передан методу GenerateOperation(OperationContractGenerationContext) для включения изменения контракта операции и его контекста перед созданием кода.

public ref class OperationContractGenerationContext
public class OperationContractGenerationContext
type OperationContractGenerationContext = class
Public Class OperationContractGenerationContext
Наследование
OperationContractGenerationContext

Примеры

В следующем примере показано использование объекта, переданного OperationContractGenerationContextIOperationContractGenerationExtension.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

Комментарии

Используйте объект, переданный OperationContractGenerationContextIOperationContractGenerationExtension.GenerateOperation методу, чтобы изменить объектную модель документа кода до создания кода. Как правило, System.ServiceModel.Description.IOperationContractGenerationExtension интерфейс реализуется в пользовательской System.ServiceModel.Description.IWsdlImportExtension реализации, которая используется для импорта пользовательских элементов WSDL или изменения кода на уровне службы или операции. Сведения об изменении кода на уровне обслуживания см. в статье System.ServiceModel.Description.IServiceContractGenerationExtension.

Конструкторы

Имя Описание
OperationContractGenerationContext(ServiceContractGenerator, ServiceContractGenerationContext, OperationDescription, CodeTypeDeclaration, CodeMemberMethod, CodeMemberMethod, CodeMemberMethod, CodeMemberMethod)

Инициализирует новый экземпляр класса с помощью указанного OperationContractGenerationContext генератора контрактов, контекста контракта, описания операций, объявления типа кода, метода синхронизации, метода begin, конечного метода и метода задачи.

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

Инициализирует новый экземпляр класса OperationContractGenerationContext.

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

Инициализирует новый экземпляр класса с помощью указанного OperationContractGenerationContext генератора контрактов, контекста контракта, описания операции, объявления типа кода и метода.

OperationContractGenerationContext(ServiceContractGenerator, ServiceContractGenerationContext, OperationDescription, CodeTypeDeclaration, 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)

Применяется к