문제

I have an attribute that I have written that has a dependency on the Data Access Layer so I made a constructor that took the DAL class as a parameter (marked with [DefaultConstructor] and another, blank, constructor that is parameterless. When I call a method that depends on the attribute how do I make StructureMap inject the correct type?

Thanks

Gareth

도움이 되었습니까?

해결책

I have been working on the same problem, i'm using something like this:

ObjectFactory.Initialize(x =>
{
    x.PullConfigurationFromAppConfig = true;
    x.SetAllProperties(p => p.TypeMatches(t => 
        t.GetCustomAttributes(typeof(InjectAttribute), true).Length > 0));
}       

I am having some issues injecting onto webform pages but it works when creating instances using ObjectFactory...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top