ServiceContractGenerationContext Klasse

Definition

Dies wird an die GenerateContract(ServiceContractGenerationContext)-Methode übergeben, um die Änderung eines Dienstvertrags und seines Kontexts vor der Codegenerierung zu ermöglichen.

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

Beispiele

Im folgenden Beispiel wird die Verwendung des ServiceContractGenerationContext-Objekts dargestellt, das an die IServiceContractGenerationExtension.GenerateContract-Methode übergeben wird, um aus benutzerdefinierten WSDL-Elementen extrahierte Codekommentare hinzuzufügen.

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

Im folgenden Codebeispiel sind die resultierenden Codecommentare dargestellt.

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

Hinweise

Verwenden Sie das ServiceContractGenerationContext-Objekt, das an die IServiceContractGenerationExtension.GenerateContract-Methode übergeben wird, um das Code Document Object Model vor der Codegenerierung zu ändern. In der Regel wird die System.ServiceModel.Description.IServiceContractGenerationExtension-Schnittstelle in einer benutzerdefinierten System.ServiceModel.Description.IWsdlImportExtension-Implementierung implementiert, die verwendet wird, um benutzerdefinierte WSDL-Elemente zu importieren oder andernfalls den Code auf Dienst- oder Vorgangsebene zu ändern. Informationen zur Änderung des Codes auf Vorgangsebene finden Sie unter System.ServiceModel.Description.IOperationContractGenerationExtension.

Konstruktoren

ServiceContractGenerationContext(ServiceContractGenerator, ContractDescription, CodeTypeDeclaration)

Initialisiert eine neue Instanz der ServiceContractGenerationContext-Klasse mit dem angegebenen Vertragsgenerator und der angegebenen Vorgangsbeschreibung und Vertrags-Codetypdeklaration.

ServiceContractGenerationContext(ServiceContractGenerator, ContractDescription, CodeTypeDeclaration, CodeTypeDeclaration)

Initialisiert eine neue Instanz der ServiceContractGenerationContext-Klasse mit dem angegebenen Vertragsgenerator und der angegebenen Vorgangsbeschreibung und Vertrags-Codetypdeklaration.

Eigenschaften

Contract

Ruft die ContractDescription für den aktuellen Vertrag ab.

ContractType

Ruft die CodeTypeDeclaration für den aktuellen Vertrag ab.

DuplexCallbackType

Ruft die CodeTypeDeclaration für den Duplexrückrufvertrag des Dienstvertrags ab.

Operations

Ruft eine Auflistung von OperationContractGenerationContext-Objekten ab, die die Vertragsvorgänge darstellen.

ServiceContractGenerator

Ruft den ServiceContractGenerator ab, mit dem der Vertrag generiert werden soll.

Methoden

Equals(Object)

Bestimmt, ob das angegebene Objekt gleich dem aktuellen Objekt ist.

(Geerbt von Object)
GetHashCode()

Fungiert als Standardhashfunktion.

(Geerbt von Object)
GetType()

Ruft den Type der aktuellen Instanz ab.

(Geerbt von Object)
MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.

(Geerbt von Object)
ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.

(Geerbt von Object)

Gilt für: