Partager via


DependencyAttribute Class

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Unity Application Block information can be found at the Unity Application Block site.

This attribute is used to mark properties and parameters as targets for injection.

Namespace:  Microsoft.Practices.Unity
Assembly:  Microsoft.Practices.Unity (in Microsoft.Practices.Unity.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Parameter, AllowMultiple := False,  _
    Inherited := True)> _
Public NotInheritable Class DependencyAttribute _
    Inherits DependencyResolutionAttribute
[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Parameter, AllowMultiple = false, 
    Inherited = true)]
public sealed class DependencyAttribute : DependencyResolutionAttribute
[AttributeUsageAttribute(AttributeTargets::Property|AttributeTargets::Parameter, AllowMultiple = false, 
    Inherited = true)]
public ref class DependencyAttribute sealed : public DependencyResolutionAttribute
public final class DependencyAttribute extends DependencyResolutionAttribute

Remarks

For properties, this attribute is necessary for injection to happen. For parameters, it's not needed unless you want to specify additional information to control how the parameter is resolved.

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.Practices.Unity.DependencyResolutionAttribute
      Microsoft.Practices.Unity.DependencyAttribute

See Also

DependencyAttribute Members

Microsoft.Practices.Unity Namespace