ServiceContractGenerationContext Klass

Definition

Skickades till GenerateContract(ServiceContractGenerationContext) metoden för att aktivera ändring av ett tjänstkontrakt och dess kontext innan kod genererades.

public ref class ServiceContractGenerationContext
public class ServiceContractGenerationContext
type ServiceContractGenerationContext = class
Public Class ServiceContractGenerationContext
Arv
ServiceContractGenerationContext

Exempel

I följande exempel visas hur ServiceContractGenerationContext objektet som skickas till IServiceContractGenerationExtension.GenerateContract metoden används för att lägga till kodkommenter som extraherats från anpassade WSDL-element.

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

I följande kodexempel visas de resulterande kodkommentarna.

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

Kommentarer

Använd objektet som ServiceContractGenerationContext skickades till IServiceContractGenerationExtension.GenerateContract metoden för att ändra koddokumentets objektmodell innan kodgenereringen. System.ServiceModel.Description.IServiceContractGenerationExtension Vanligtvis implementeras gränssnittet på en anpassad System.ServiceModel.Description.IWsdlImportExtension implementering som används för att importera anpassade WSDL-element eller på annat sätt ändra koden på tjänst- eller åtgärdsnivå. Information om hur du ändrar koden på åtgärdsnivå finns System.ServiceModel.Description.IOperationContractGenerationExtensioni .

Konstruktorer

Name Description
ServiceContractGenerationContext(ServiceContractGenerator, ContractDescription, CodeTypeDeclaration, CodeTypeDeclaration)

Initierar en ny instans av klassen med hjälp av den angivna kontraktsgeneratorn, kontraktsbeskrivningen och deklarationen av ServiceContractGenerationContext kontraktskodstyp.

ServiceContractGenerationContext(ServiceContractGenerator, ContractDescription, CodeTypeDeclaration)

Initierar en ny instans av klassen med hjälp av den angivna kontraktsgeneratorn, kontraktsbeskrivningen och deklarationen av ServiceContractGenerationContext kontraktskodstyp.

Egenskaper

Name Description
Contract

ContractDescription Hämtar för det aktuella kontraktet.

ContractType

CodeTypeDeclaration Hämtar för det aktuella kontraktet.

DuplexCallbackType

CodeTypeDeclaration Hämtar för återanropskontraktet för duplex i tjänstkontraktet.

Operations

Hämtar en samling OperationContractGenerationContext objekt som representerar kontraktsåtgärderna.

ServiceContractGenerator

Hämtar det ServiceContractGenerator som ska generera kontraktet.

Metoder

Name Description
Equals(Object)

Avgör om det angivna objektet är lika med det aktuella objektet.

(Ärvd från Object)
GetHashCode()

Fungerar som standard-hash-funktion.

(Ärvd från Object)
GetType()

Hämtar den aktuella instansen Type .

(Ärvd från Object)
MemberwiseClone()

Skapar en ytlig kopia av den aktuella Object.

(Ärvd från Object)
ToString()

Returnerar en sträng som representerar det aktuella objektet.

(Ärvd från Object)

Gäller för