C# Structuremap,为从类派生的所有实例调用SetProperty
StructureMap 3中将SetProperty应用于从特定类派生的所有接口的最佳方法是什么?我有很多很多这样的课程C# Structuremap,为从类派生的所有实例调用SetProperty,c#,structuremap,structuremap3,C#,Structuremap,Structuremap3,StructureMap 3中将SetProperty应用于从特定类派生的所有接口的最佳方法是什么?我有很多很多这样的课程 public class FooBarProxy : Proxy, IFooBarProxy { public string BaseAddress { get; set; } } 我想做类似的事情(利用SetProperty的延迟直到实例化之后) 谢谢 scanner.For<IFooBarProxy>.Use(FooBarProxy) .S
public class FooBarProxy : Proxy, IFooBarProxy
{
public string BaseAddress { get; set; }
}
我想做类似的事情(利用SetProperty的延迟直到实例化之后)
谢谢
scanner.For<IFooBarProxy>.Use(FooBarProxy)
.SetProperty(m => m.BaseAddress = GetBaseAddress())
public class WebApiProxyConvention2 : IRegistrationConvention
{
public void Process(System.Type proxyType, StructureMap.Configuration.DSL.Registry registry)
{
// derived from FooBar.WebApiProxies.Proxy?
if (!proxyType.IsSubclassOf(typeof(FooBar.WebApiProxies.Proxy)))
{
return;
}
// get the matching interface
var proxyInterface = proxyType.GetInterface("I" + proxyType.Name);
registry.For(proxyInterface).Use(proxyType)
.????? // answer goes here.
}
}