ContractDescription.GetContract 方法

定义

返回指定类型的协定的协定说明。

重载

GetContract(Type, Type)

返回指定类型的协定和指定类型的服务的协定说明。

GetContract(Type, Object)

返回指定类型的协定和服务实现的协定说明。

GetContract(Type)

返回指定类型的协定的协定说明。

注解

GetContract 重载之间的区别是,带有两个参数的重载允许您从服务查找属性(例如,OperationBehaviorAttribute)。

GetContract(Type, Type)

返回指定类型的协定和指定类型的服务的协定说明。

public:
 static System::ServiceModel::Description::ContractDescription ^ GetContract(Type ^ contractType, Type ^ serviceType);
public static System.ServiceModel.Description.ContractDescription GetContract (Type contractType, Type serviceType);
static member GetContract : Type * Type -> System.ServiceModel.Description.ContractDescription
Public Shared Function GetContract (contractType As Type, serviceType As Type) As ContractDescription

参数

contractType
Type

协定的 Type

serviceType
Type

服务的 Type

返回

ContractDescription

指定类型的协定和指定类型的服务的 ContractDescription

示例

ContractDescription cd4 = ContractDescription.GetContract(typeof(ICalculator), typeof(CalculatorService));
Dim cd4 As ContractDescription = ContractDescription.GetContract(GetType(ICalculator), GetType(CalculatorService))

注解

GetContract 重载之间的区别是,带有两个参数的重载允许您从服务查找属性(例如,OperationBehaviorAttribute)。

适用于

GetContract(Type, Object)

返回指定类型的协定和服务实现的协定说明。

public:
 static System::ServiceModel::Description::ContractDescription ^ GetContract(Type ^ contractType, System::Object ^ serviceImplementation);
public static System.ServiceModel.Description.ContractDescription GetContract (Type contractType, object serviceImplementation);
static member GetContract : Type * obj -> System.ServiceModel.Description.ContractDescription
Public Shared Function GetContract (contractType As Type, serviceImplementation As Object) As ContractDescription

参数

contractType
Type

协定的 Type

serviceImplementation
Object

实现服务的 Object

返回

ContractDescription

指定类型的协定和服务实现的 ContractDescription

示例

CalculatorService calcSvc = new CalculatorService();
ContractDescription cd3 = ContractDescription.GetContract(typeof(ICalculator), calcSvc);
Dim calcSvc As New CalculatorService()
Dim cd3 As ContractDescription = ContractDescription.GetContract(GetType(ICalculator), calcSvc)

注解

GetContract 重载之间的区别是,带有两个参数的重载允许您从服务查找属性(例如,OperationBehaviorAttribute)。

适用于

GetContract(Type)

返回指定类型的协定的协定说明。

public:
 static System::ServiceModel::Description::ContractDescription ^ GetContract(Type ^ contractType);
public static System.ServiceModel.Description.ContractDescription GetContract (Type contractType);
static member GetContract : Type -> System.ServiceModel.Description.ContractDescription
Public Shared Function GetContract (contractType As Type) As ContractDescription

参数

contractType
Type

协定的 Type

返回

ContractDescription

指定类型的协定的 ContractDescription

示例

ContractDescription cd2 = ContractDescription.GetContract(typeof(ICalculator));
Dim cd2 As ContractDescription = ContractDescription.GetContract(GetType(ICalculator))

注解

GetContract 重载之间的区别是,带有两个参数的重载允许您从服务查找属性(例如,OperationBehaviorAttribute)。

适用于