dhpirkle
06-12-2007, 12:17 AM
How can I specify a type attribute for an object where the type is a generic type, and I want to pass a non-system type parameter to the generic? If the type parameter is something like int, it's easy:
<object name="test" type="MyClass<int>, MyLib">
If I want to use "MyOtherClass, MyOtherLib" (MyOtherClass from the MyOtherLib assembly) as the type parameter instead of "int", then I run into trouble:
<object name="test" type="MyClass<MyOtherClass, MyOtherLib>, MyLib">
That's treated like a generic with 2 type parameters.
The documentation suggests that you use aliases. That's fine, but I want to have the whole definition captured in the objects section in an xml file outside of app.config, so I don't want to put the aliases in the app.config file, one approach that is mentioned in the documentation.
There's a TypeAliasConfigurer class that is mentioned for defining aliases withinin the objects section. However, this doesn't seem to be called until after the alias needs to be resolved. If I try to use an alias, an exception is thrown without the breakpoint I set in TypeAliasConfigurer is ever being triggered. If I remove the <object> that uses the alias in its type attribute, the breakpoint is triggered. So TypeAliasConfigurer is called, it just seems to happen too late in the spring life cycle to be of any use.
Any suggestions on how to solve this - either using aliases or not?
<object name="test" type="MyClass<int>, MyLib">
If I want to use "MyOtherClass, MyOtherLib" (MyOtherClass from the MyOtherLib assembly) as the type parameter instead of "int", then I run into trouble:
<object name="test" type="MyClass<MyOtherClass, MyOtherLib>, MyLib">
That's treated like a generic with 2 type parameters.
The documentation suggests that you use aliases. That's fine, but I want to have the whole definition captured in the objects section in an xml file outside of app.config, so I don't want to put the aliases in the app.config file, one approach that is mentioned in the documentation.
There's a TypeAliasConfigurer class that is mentioned for defining aliases withinin the objects section. However, this doesn't seem to be called until after the alias needs to be resolved. If I try to use an alias, an exception is thrown without the breakpoint I set in TypeAliasConfigurer is ever being triggered. If I remove the <object> that uses the alias in its type attribute, the breakpoint is triggered. So TypeAliasConfigurer is called, it just seems to happen too late in the spring life cycle to be of any use.
Any suggestions on how to solve this - either using aliases or not?