Cine
Cine

Reputation: 4392

Resolve parameters with a custom class

I have a Domain Specific Language, and I would like to register objects that can be instantiated inside.

For instance a class that can do httprequests.

[IoC("HttpRequest", typeof(DslScriptObject), IoCAttribute.IoCLifestyleType.Transient)]
internal class WebRequestDslObj : DslScriptObject
{
    [DslNew]
    public WebRequestDslObj() : this(null, null)
    {}
    [DslNew]
    public WebRequestDslObj([DslParam("uri")]string uristring, [DslOptionalParam("contenttype")] string contenttype) : this(uristring, null)
    {}
}

I then have a class that maps types from my dsl datatypes to c# datatypes (I have them as an IList if that makes any difference), and this works ok, if I do not use Castle to instantiate the object.

But as soon as I want to use IoC to autoregister the various types, then I dont know what to do about the constructors. I have tried to look at setting a CustomComponentActivator, but I got stuck at not being able to find any good example or documentation. Is that a viable path to take? (and will I be able to get around the funny special case for null parameters?)

Anyone have an example of where I can start?

Upvotes: 0

Views: 278

Answers (1)

Krzysztof Kozmic
Krzysztof Kozmic

Reputation: 27374

So what are you trying to do with Windsor, because I'm not sure I see where you're going with it...

If you want to affect how component gets register in Windsor, for example rename parameters, you can write custom ComponentModel construction contributor to do it.

Upvotes: 2

Related Questions