0

Is there a way to get the string representation of an interface using Spring.NET?

In code:

typeof(ISsoUrlTemplateRepository).Name

I would need this name in Spring.NET configuration... I could just take the string itself but if I would ever refactor and change the names of some interfaces, the Spring configuration wouldn't work anymore.

This relates to another question I've asked --> Configure static properties with spring.NET

Community
  • 1
  • 1
Lieven Cardoen
  • 25,140
  • 52
  • 153
  • 244
  • I don't see what "to get the string representation of an interface" has to do with Spring.NET. – Andre Pena Jan 10 '10 at 20:08
  • Related: http://stackoverflow.com/questions/8433676/ioc-spring-net-injecting-system-type/8438819. In this question a nice summary is given of different ways to inject type in spring.net using xml config. – Marijn Dec 09 '11 at 10:49

2 Answers2

2

To get a typename in your Spring.NET config you need to use Spring Expression language.

Like so:

<object id="MyClass" type="Assembly.Type, Assembly">
    <property name ="MyTypeProperty" value="T(AnotherAssembly.AnotherType, AnotherAssembly)"/>        
 </object>
BennyM
  • 2,796
  • 16
  • 24
0

By using

typeof(ISsoUrlTemplateRepository).AssemblyQualifiedName

Which includes full type name, plus assembly name from which that was loaded.

Rubens Farias
  • 57,174
  • 8
  • 131
  • 162