开发者

DynamicParameters in .config file

I'm in a situation, where I need to do something similar to the following:

public static class mystaticclass
{
    public static string filename { get; private set; }

    static mystaticclass()
    {
        filename = "C:\\test.test";
    }
}

public class myclass
{
    public string filename;
    public myclass(string filename)
    {
        this.filename = filename;
    }
}


[TestClass]
public class UnitTest1
{
    [TestMethod]
    public void TestMethod1()
    {
        var container = new WindsorContainer().Install(Configuration.FromXmlFile("Windsor.config"));
        container.Register(Component.For<myclass>()
            .DynamicParameters((k, d) =>
                {
    开发者_JAVA百科                d["filename"] = mystaticclass.filename;
                }));

        var tmp=container.Resolve<myclass>();
    }
}

however I'd very much like to configure this in the .config file, rather than in code.... is it possible?? ... probably not... so what would be a good alternative solution

N.B. the 'mystaticclass' is not something I'm able to change, however I'd like to be able to use mystaticclass2.filename in some configurations....

TIA

Sørn


Nope, not possible with XML, mostly because dynamic parameters are... well - dynamnic and that's something that can't be expressed in XML. Your case looks pretty static, so guess if you really think that's what you want you might quite easily implement support for that via IContributeComponentModelConstruction

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜