BindingElement.GetProperty<T> Method (BindingContext)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Namespace:   System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public abstract T GetProperty<T>(
	BindingContext context
)
where T : class

Parameters

context
Type: System.ServiceModel.Channels.BindingContext

The BindingContext for the binding element.

Return Value

Type: T

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

Type Parameters

T

The typed object for which the method is querying.

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.

System_CAPS_noteNote

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.

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);

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: