I use DependsOn for static dependencies such as connection strings. What is the equivalent function for Unity's Fluent interface?
A:
You can just pass the value directly in the RegisterType call as the value for a parameter or property.
For example, if you have this class:
public class Clock {
public Clock(int startTicks) { ... }
public Clock(DateTime startTime) { ... }
}
You could configure this like so:
container.RegisterType<Clock>(
new InjectionConstructor(154324));
and it'll pass that integer to the constructor that takes a single int. If you'd passed a DateTime instead, it'd call the other constructor.
Chris Tavares
2010-10-28 17:31:42