Newbie Microsoft Unity question.
How do I specify the config to initialize a simple string type.
I'm thinking of the below... but it doesn't like the char[] paramater in the constructor.
<register type="string" name="myString" >
<constructor&开发者_如何学Cgt;
<param name="char[]" value="SomeValue">
</param>
</constructor>
</register>
Why don't inject the URL into the object using it, instead of leaving it to call Resolve?
public interface IMyService {
void DoSomething();
}
public class MyServiceRemote : IMyService {
private readonly _url;
public MyServiceRemote(string url) {
_url = url;
}
public void DoSomething() {
...
}
}
and, in the config:
<register type="IMyService" mapTo="MyServiceRemote" >
<constructor>
<param name="url" value="SomeValue">
</param>
</constructor>
</register>
精彩评论