Click or drag to resize

ServiceMetadataTypeAttribute Class

Specifies the metadata class to associate with a service implementation.
Inheritance Hierarchy

Namespace:  Autofac.Multitenant.Wcf
Assembly:  Autofac.Multitenant.Wcf (in Autofac.Multitenant.Wcf.dll) Version: 4.0.0-CI-234
[AttributeUsageAttribute(AttributeTargets.Interface, AllowMultiple = false)]
public sealed class ServiceMetadataTypeAttribute : Attribute

The ServiceMetadataTypeAttribute type exposes the following members.

Public methodServiceMetadataTypeAttribute
Initializes a new instance of the ServiceMetadataTypeAttribute class.
Public propertyMetadataClassType
Gets the metadata class type.
Public propertyTypeId
When implemented in a derived class, gets a unique identifier for this Attribute.
(Inherited from Attribute.)
Public methodEquals
Returns a value that indicates whether this instance is equal to a specified object.
(Inherited from Attribute.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Returns the hash code for this instance.
(Inherited from Attribute.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsDefaultAttribute
When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
(Inherited from Attribute.)
Public methodMatch
When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
(Inherited from Attribute.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Explicit Interface Implementations
Explicit interface implementationPrivate method_AttributeGetIDsOfNames
Maps a set of names to a corresponding set of dispatch identifiers.
(Inherited from Attribute.)
Explicit interface implementationPrivate method_AttributeGetTypeInfo
Retrieves the type information for an object, which can be used to get the type information for an interface.
(Inherited from Attribute.)
Explicit interface implementationPrivate method_AttributeGetTypeInfoCount
Retrieves the number of type information interfaces that an object provides (either 0 or 1).
(Inherited from Attribute.)
Explicit interface implementationPrivate method_AttributeInvoke
Provides access to properties and methods exposed by an object.
(Inherited from Attribute.)

When hosting a service in a multitenant environment using AutofacHostFactory and the dynamic proxy generation that occurs therein, you can't really mark your "service implementation class" with metadata attributes like the ServiceBehaviorAttribute. Also, since many of these attributes require you to mark a class rather than the service interface, there's no way to otherwise specify them.

This attribute works similar to the System.ComponentModel.DataAnnotations.MetadataTypeAttribute and allows you to mark a service interface such that the generated dynamic proxy class will use a "metadata buddy class" to retrieve various attributes that should be applied during generation.

Mark your service interface with one of these attributes, then create an empty class with the ServiceBehaviorAttribute (or whatever) associated with it. The dynamic proxy generation will copy these attributes, thus allowing you to still make use of service metadata info.

This is particularly handy when choosing to specify a service name. Since WCF usually infers the service name (which is also the name of the service element in configuration that it uses to set up the service host) from the type of the implementation, a dynamic proxy implementation results in service names like Castle.Proxies.IMyServiceProxy_1. To manually specify the name, you use the Name property, which can be associated with a service metadata buddy class.

See Also