The below function throws an exception (in my case when it tries to
instantiate a component interface), if the mappedClass is an
interface, shouldn't it goto the second/third elseif part and use
either the optomized creator or the bytecode provider to look up the
type?  (This way you could have the interface type in your IoC/DI
setup and it would create it etc).  Or am i just misunderstanding
something?  This works for everything else (i have interfaces
everywhere instead of concrete classes and use DI to set them up for
nhibernate) but for my component i get this exception.  Is this a bug
or to be expected?  Also if it is to be expected, why?  Can this be
fixed? (Reorder the if so that if it dosn't find it in the IoC then it
throws the exception maybe?) If not is there a work around or am i
doing things totally wrong?  Thank you!
public object Instantiate()
                {
                        if (ReflectHelper.IsAbstractClass(mappedClass))
                        {
                                throw new InstantiationException("Cannot 
instantiate abstract
class or interface: ", mappedClass);
                        }
                        else if (optimizer != null)
                        {
                                return optimizer.CreateInstance();
                        }
                        else if (mappedClass.IsValueType)
                        {
                                return
Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(mappedClass,
true);
                        }
                        else if (constructor == null)
                        {
                                throw new InstantiationException("No default 
constructor for
entity: ", mappedClass);
                        }
                        else
                        {
                                try
                                {
                                        return constructor.Invoke(null);
                                }
                                catch (Exception e)
                                {
                                        throw new InstantiationException("Could 
not instantiate entity:
", e, mappedClass);
                                }
                        }
                }

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.

Reply via email to