I have an interface as shown below (simplified) and it has an
implementation that is registered for it.

public interface IPreference
{
    Type PreferenceType { get; set; }
}

public class MyPreference
{
    public MyPreference(Type type)
    {
        // Type is required in the construction process
        Type = type;
    }

    public Type Type { get; set; }
}

When I try to resolve it out with any basic type (int, string) it
works as expected.

Dictionary<string, object> args = new Dictionary<string, object>()
{ "type", typeof(Int32) };
var preference = Container.Resolve<IPreference>(args);

When I try to resolve it out with an enumeration type it fails
miserably with a ConverterException telling me that it cannot convert
MyEnumeration to System.Type.

public enum MyEnumeration
{
    One = 1,
    Two = 2,
    Three = 3
}

Dictionary<string, object> args = new Dictionary<string, object>()
{ "type", typeof(MyEnumeration) };
// Exception is thrown here at resolution time
var preference = Container.Resolve<IPreference>(args);

Am I missing something completely obvious here?

--

You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.


Reply via email to