Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Structuremap,为从类派生的所有实例调用SetProperty_C#_Structuremap_Structuremap3 - Fatal编程技术网

C# Structuremap,为从类派生的所有实例调用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

StructureMap 3中将SetProperty应用于从特定类派生的所有接口的最佳方法是什么?我有很多很多这样的课程

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.
    }
}