Esempio n. 1
0
        private ConstructorInfo ResolveConstructor(String path)
        {
            string importedClassName = SessionFactoryHelper.GetImportedClassName(path);
            string className         = StringHelper.IsEmpty(importedClassName) ? path : importedClassName;

            if (className == null)
            {
                throw new SemanticException("Unable to locate class [" + path + "]");
            }
            try
            {
                System.Type holderClass = ReflectHelper.ClassForName(className);
                return(ReflectHelper.GetConstructor(holderClass, _constructorArgumentTypes));
            }
            catch (TypeLoadException e)
            {
                throw new QueryException("Unable to locate class [" + className + "]", e);
            }
            catch (InstantiationException e)
            {
                // this is the exception returned by ReflectHelper.getConstructor() if it cannot
                // locate an appropriate constructor
                throw new QueryException("Unable to locate appropriate constructor on class [" + className + "]", e);
            }
        }
Esempio n. 2
0
 public void ConstructorNotFound()
 {
     try
     {
         ReflectHelper.GetConstructor(typeof(SomeClass), new IType[] { NHibernateUtil.String });
         Assert.Fail("Should have thrown an exception");
     }
     catch (InstantiationException e)
     {
         Assert.IsTrue(e.Message.IndexOf("String") >= 0);
         Assert.IsTrue(e.Message.IndexOf(typeof(SomeClass).ToString()) >= 0);
     }
 }