IServiceContractGenerationExtension Arabirim
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Bir hizmet sözleşmesi için oluşturulan kodu değiştirmek için kullanılabilecek sözleşme oluşturma sırasında çağrılan yöntemleri tanımlar.
public interface class IServiceContractGenerationExtension
public interface IServiceContractGenerationExtension
type IServiceContractGenerationExtension = interface
Public Interface IServiceContractGenerationExtension
Örnekler
Aşağıdaki kod örneği, çağrısı ImportContractsırasında özelliğine ContractDescription.Behaviors nasıl ekleneceğini IServiceContractGenerationExtension gösterir.
public void ImportContract(WsdlImporter importer, WsdlContractConversionContext context)
{
Console.Write("ImportContract");
// Contract Documentation
if (context.WsdlPortType.Documentation != null)
{
context.Contract.Behaviors.Add(new WsdlDocumentationImporter(context.WsdlPortType.Documentation));
}
// Operation Documentation
foreach (Operation operation in context.WsdlPortType.Operations)
{
if (operation.Documentation != null)
{
OperationDescription operationDescription = context.Contract.Operations.Find(operation.Name);
if (operationDescription != null)
{
operationDescription.Behaviors.Add(new WsdlDocumentationImporter(operation.Documentation));
}
}
}
}
Aşağıdaki kod örnekleri, bir hizmet sözleşmesi için oluşturulan koda açıklama ekleyen uygulamasını GenerateContract gösterir.
public void GenerateContract(ServiceContractGenerationContext context)
{
Console.WriteLine("In generate contract.");
context.ContractType.Comments.AddRange(Formatter.FormatComments(commentText));
}
Aşağıdaki kod örneği, hizmet sözleşmesi üzerinde oluşturulan açıklamaları gösterir.
/// From WSDL Documentation:
///
/// <summary>The string for the Name data member.</summary>
///
[System.Runtime.Serialization.DataMemberAttribute()]
public string Name
{
get
{
return this.NameField;
}
set
{
this.NameField = value;
}
}
'''From WSDL Documentation:
'''
'''<summary>The string for the Name data member.</summary>
'''
<System.Runtime.Serialization.DataMemberAttribute()> _
Public Property Name() As String
Get
Return Me.NameField
End Get
Set
Me.NameField = value
End Set
End Property
Açıklamalar
IServiceContractGenerationExtension Bir sözleşme veya uç nokta kod olarak derlendiğinde oluşturulan kodu değiştirmenize olanak tanımak için bir sözleşme davranışında (System.ServiceModel.Description.IContractBehaviortür) arabirimini uygulayın.
Genellikle, özel System.ServiceModel.Description.IWsdlImportExtension bir özel sözleşme davranışı veya ImportEndpointçağrısı sırasında koleksiyona ContractDescription.BehaviorsImportContract ekler.
Yöntemler
| Name | Description |
|---|---|
| GenerateContract(ServiceContractGenerationContext) |
Sözleşme oluşturma işleminden önce kod belgesi nesne modelini değiştirmek için uygulayın. |