Class OptionalParameter
A ParameterValue that can be passed to RegisterType(Type, Type, String, ITypeLifetimeManager, InjectionMember[]) to configure a parameter or property as an optional dependency.
Inherited Members
Namespace: Unity.Injection
Assembly: Unity.Abstractions.dll
Syntax
public class OptionalParameter : ParameterBase, IEquatable<Type>, IResolverFactory<Type>, IResolverFactory<ParameterInfo>
Constructors
| Improve this Doc View SourceOptionalParameter()
Construct a new OptionalParameter instance that specifies to optionally resolve whatever Type specified at this position
Declaration
public OptionalParameter()
OptionalParameter(String)
Construct a new OptionalParameter object that
specifies the given name
.
Declaration
public OptionalParameter(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name for the dependency. |
OptionalParameter(Type)
Construct a new OptionalParameter object that
specifies the given type
.
Declaration
public OptionalParameter(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type of the dependency. |
OptionalParameter(Type, String)
Construct a new OptionalParameter object that
specifies the given type
and name
.
Declaration
public OptionalParameter(Type type, string name)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type of the dependency. |
String | name | Name for the dependency. |
Methods
| Improve this Doc View SourceGetResolver<TContext>(ParameterInfo)
Declaration
public ResolveDelegate<TContext> GetResolver<TContext>(ParameterInfo info)
where TContext : IResolveContext
Parameters
Type | Name | Description |
---|---|---|
ParameterInfo | info |
Returns
Type | Description |
---|---|
ResolveDelegate<TContext> |
Type Parameters
Name | Description |
---|---|
TContext |
GetResolver<TContext>(Type)
Declaration
public ResolveDelegate<TContext> GetResolver<TContext>(Type type)
where TContext : IResolveContext
Parameters
Type | Name | Description |
---|---|---|
Type | type |
Returns
Type | Description |
---|---|
ResolveDelegate<TContext> |
Type Parameters
Name | Description |
---|---|
TContext |