Export (0) Print
Expand All

ContractDescription Class

Describes a Windows Communication Foundation (WCF) contract that specifies what an endpoint communicates to the outside world.

System.Object
  System.ServiceModel.Description.ContractDescription

Namespace:  System.ServiceModel.Description
Assemblies:   System.ServiceModel.Primitives (in System.ServiceModel.Primitives.dll)
  System.ServiceModel (in System.ServiceModel.dll)

type ContractDescription =  class end

The ContractDescription type exposes the following members.

  NameDescription
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContractDescription(String)Initializes a new instance of the ContractDescription class with a specified name.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsContractDescription(String, String)Initializes a new instance of the ContractDescription class with a namespace-qualified name specified.
Top

  NameDescription
Public propertyBehaviorsGets the behaviors associated with the contract description.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsCallbackContractTypeGets or sets the type of callback contract that the contract description specifies.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsConfigurationNameGets or sets the configuration name for the contract description.
Public propertySupported in .NET for Windows Store appsContractBehaviorsGets the collection of behavior for the contract.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsContractTypeGets or sets the contract type that the contract description specifies.
Public propertyHasProtectionLevelGets a value that indicates whether the contract has had a protection level set.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsNameGets or sets the name of the contract.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsNamespaceGets or sets the namespace for the contract.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsOperationsGets the collection of operation descriptions associated with the contract.
Public propertyProtectionLevelGets or sets the level of security protection associated with the contract.
Public propertySessionModeGets or sets a value that indicates whether a session is required by the contract.
Top

  NameDescription
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodStatic memberGetContract(Type)Returns the contract description for a specified type of contract.
Public methodStatic memberGetContract(Type, Object)Returns the contract description for a specified type of contract and service implementation.
Public methodStatic memberGetContract(Type, Type)Returns the contract description for a specified type of contract and a specified type of service.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetInheritedContractsReturns a collection of contract descriptions that are inherited by the current contract description.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodShouldSerializeProtectionLevelReturns a value that indicates whether the ProtectionLevel property has changed from its default value and should be serialized.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsToStringReturns a string that represents the current object. (Inherited from Object.)
Top

A WCF contract is a collection of operations that specifies what the endpoint communicates to the outside world. Each operation is a message exchange. For example, a request message and an associated reply message form a request/reply message exchange.

A ContractDescription object is used to describe WCF contracts and their operations. Within a ContractDescription, each contract operation has a corresponding OperationDescription that describes aspects of the each operation that is part of the contract, such as whether the operation is one-way or request/reply. Each OperationDescription also describes the messages that make up the operation using a MessageDescriptionCollection. ContractDescription contains a reference to an interface that defines the contract using the programming model. This interface is marked with ServiceContractAttribute and its methods that correspond to endpoint operations are marked with the OperationContractAttribute.

A duplex contract defines the following logical sets of operations:

  • A set that the service exposes for the client to call.

  • A set that the client exposes for the service to call.

The programming model for defining a duplex contract is to split each set in a separate interface and apply attributes to each interface. In this case, ContractDescription contains a reference to each of the interfaces that groups them into one duplex contract.

Similar to bindings, each contract has a Name and Namespace that uniquely identify it in the metadata of the service.

The following example shows a number of ways to create or retrieve a ContractDescription object. It then displays the various pieces of information that are stored in the ContractDescription object.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft