Прочетете на английски Редактиране

Споделяне чрез


ContractDescription.GetContract Method

Definition

Returns the contract description for a specified type of contract.

Overloads

GetContract(Type, Type)

Returns the contract description for a specified type of contract and a specified type of service.

GetContract(Type, Object)

Returns the contract description for a specified type of contract and service implementation.

GetContract(Type)

Returns the contract description for a specified type of contract.

Remarks

The difference between the GetContract overloads is that the ones with two arguments allow you to find attributes from the service (for example, OperationBehaviorAttribute).

GetContract(Type, Type)

Source:
ContractDescription.cs
Source:
ContractDescription.cs

Returns the contract description for a specified type of contract and a specified type of service.

C#
public static System.ServiceModel.Description.ContractDescription GetContract(Type contractType, Type serviceType);

Parameters

contractType
Type

The Type of contract.

serviceType
Type

The Type of service.

Returns

The ContractDescription for the specified type of contract and type of service.

Examples

C#
ContractDescription cd4 = ContractDescription.GetContract(typeof(ICalculator), typeof(CalculatorService));

Remarks

The difference between the GetContract overloads is that the ones with two arguments allow you to find attributes from the service (for example, OperationBehaviorAttribute).

Applies to

.NET Framework 4.8.1 и други версии
Продукт Версии
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

GetContract(Type, Object)

Source:
ContractDescription.cs
Source:
ContractDescription.cs

Returns the contract description for a specified type of contract and service implementation.

C#
public static System.ServiceModel.Description.ContractDescription GetContract(Type contractType, object serviceImplementation);

Parameters

contractType
Type

The Type of contract.

serviceImplementation
Object

The Object that implements the service.

Returns

The ContractDescription for the specified type of contract and service implementation.

Examples

C#
CalculatorService calcSvc = new CalculatorService();
ContractDescription cd3 = ContractDescription.GetContract(typeof(ICalculator), calcSvc);

Remarks

The difference between the GetContract overloads is that the ones with two arguments allow you to find attributes from the service (for example, OperationBehaviorAttribute).

Applies to

.NET Framework 4.8.1 и други версии
Продукт Версии
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

GetContract(Type)

Source:
ContractDescription.cs
Source:
ContractDescription.cs

Returns the contract description for a specified type of contract.

C#
public static System.ServiceModel.Description.ContractDescription GetContract(Type contractType);

Parameters

contractType
Type

The Type of contract.

Returns

The ContractDescription for the specified type of contract.

Examples

C#
ContractDescription cd2 = ContractDescription.GetContract(typeof(ICalculator));

Remarks

The difference between the GetContract overloads is that the ones with two arguments allow you to find attributes from the service (for example, OperationBehaviorAttribute).

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)