Thursday, February 18, 2010

fixed my " TypeLoadException: Could not load type from string value" error

3.2.4.1. Object creation of generic types via constructor invocation
The following examples shows the definition of simple generic types and how they can be created in Spring's XML based configuration file.
namespace GenericsPlay
{
public class FilterableList<T>
{
private List<T> list;
private String name;

public List<T> Contents
{
get { return list; }
set { list = value; }
}

public String Name
{
get { return name; }
set { name = value; }
}

public List<T> ApplyFilter(string filterExpression)
{
/// should really apply filter to list ;)
return new List<T>();
}
}
}

The XML configuration to create and configure this object is shown below

<object id="myFilteredIntList" type="GenericsPlay.FilterableList&lt;int&gt;, GenericsPlay">
<property name="Name" value="My Integer List"/>
</object>

Chapter 3. Objects, Object Factories, and Application Contexts

No comments: