Editare

Partajați prin


BindingElement.GetProperty<T>(BindingContext) Method

Definition

When overridden in a derived class, returns a typed object requested, if present, from the appropriate layer in the binding stack.

public:
generic <typename T>
 where T : class abstract T GetProperty(System::ServiceModel::Channels::BindingContext ^ context);
public abstract T GetProperty<T> (System.ServiceModel.Channels.BindingContext context) where T : class;
abstract member GetProperty : System.ServiceModel.Channels.BindingContext -> 'T (requires 'T : null)
Public MustOverride Function GetProperty(Of T As Class) (context As BindingContext) As T

Type Parameters

T

The typed object for which the method is querying.

Parameters

context
BindingContext

The BindingContext for the binding element.

Returns

T

The typed object T requested if it is present or null if it is not present.

Examples

CustomBinding binding = new CustomBinding();
HttpTransportBindingElement element = new HttpTransportBindingElement();
BindingParameterCollection parameters = new BindingParameterCollection();
parameters.Add(new ServiceCredentials());
Uri baseAddress = new Uri("http://localhost:8000/ChannelApp");
String relAddress = "http://localhost:8000/ChannelApp/service";
BindingContext context = new BindingContext(binding, parameters, baseAddress, relAddress, ListenUriMode.Explicit);

ServiceCredentials serviceCredentials = element.GetProperty<ServiceCredentials>(context);

Remarks

Use this to retrieve capabilities, requirements and parameters from the binding element stack. If a binding element supports returning the requested object, it returns it. If not, it delegates the call down to the next binding element in the stack. If it gets to the bottom of the stack and no binding element supported the requested object, then the method returns null.

Note

If you are adding message headers that must be encrypted you must return a ChannelProtectionRequirements instance with your requirements from this method when asked for ChannelProtectionRequirements.

Applies to