I have a code:
[Dependency] public string MyProperty { get; set; }
While DependencyAttribute
class has property Name
.
What value will it contain in this case?
Will it be null
or nameof(MyProperty)
?
Unfortunately I have not seen source code of the DependencyAttribute
class yet. Maybe someone can provide the link.
Thanks in advance!
The value will be null. In the absence of an explicit name, null is the default name used by Unity (e.g. in calls toRegisterType()
). In terms of DependencyAttribute
specifically:
public DependencyAttribute()
: this(null) { }
/// <summary>
/// Create an instance of <see cref="DependencyAttribute"/> with the given name.
/// </summary>
/// <param name="name">Name to use when resolving this dependency.</param>
public DependencyAttribute(string name)
{
this.name = name;
}