ServiceContractGenerationContext Klas

Definitie

Doorgegeven aan de GenerateContract(ServiceContractGenerationContext) methode om de wijziging van een servicecontract en de context ervan in te schakelen voordat code wordt gegenereerd.

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

Voorbeelden

In het volgende voorbeeld ziet u het gebruik van het ServiceContractGenerationContext object dat is doorgegeven aan de IServiceContractGenerationExtension.GenerateContract methode om codeopmerkingen toe te voegen die zijn geëxtraheerd uit aangepaste WSDL-elementen.

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

In het volgende codevoorbeeld ziet u de resulterende codeopmerkingen.

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

Opmerkingen

Gebruik het ServiceContractGenerationContext object dat is doorgegeven aan de IServiceContractGenerationExtension.GenerateContract methode om het codedocumentobjectmodel te wijzigen vóór het genereren van code. Normaal gesproken wordt de System.ServiceModel.Description.IServiceContractGenerationExtension interface geïmplementeerd in een aangepaste System.ServiceModel.Description.IWsdlImportExtension implementatie die wordt gebruikt om aangepaste WSDL-elementen te importeren of de code op service- of bewerkingsniveau te wijzigen. Als u de code op bewerkingsniveau wilt wijzigen, raadpleegt u System.ServiceModel.Description.IOperationContractGenerationExtension.

Constructors

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

Initialiseert een nieuw exemplaar van de ServiceContractGenerationContext klasse met behulp van de opgegeven contractgenerator, contractbeschrijving en declaratie van het type contractcode.

ServiceContractGenerationContext(ServiceContractGenerator, ContractDescription, CodeTypeDeclaration)

Initialiseert een nieuw exemplaar van de ServiceContractGenerationContext klasse met behulp van de opgegeven contractgenerator, contractbeschrijving en declaratie van het type contractcode.

Eigenschappen

Name Description
Contract

Hiermee haalt u het ContractDescription voor het huidige contract op.

ContractType

Hiermee haalt u het CodeTypeDeclaration voor het huidige contract op.

DuplexCallbackType

Hiermee haalt u het CodeTypeDeclaration contract voor dubbelzijdige callback op in het servicecontract.

Operations

Hiermee haalt u een verzameling OperationContractGenerationContext objecten op die de contractbewerkingen vertegenwoordigen.

ServiceContractGenerator

Hiermee wordt het ServiceContractGenerator contract gegenereerd.

Methoden

Name Description
Equals(Object)

Bepaalt of het opgegeven object gelijk is aan het huidige object.

(Overgenomen van Object)
GetHashCode()

Fungeert als de standaardhashfunctie.

(Overgenomen van Object)
GetType()

Hiermee haalt u de Type huidige instantie op.

(Overgenomen van Object)
MemberwiseClone()

Hiermee maakt u een ondiepe kopie van de huidige Object.

(Overgenomen van Object)
ToString()

Retourneert een tekenreeks die het huidige object vertegenwoordigt.

(Overgenomen van Object)

Van toepassing op