Esempio n. 1
0
 public T CompileAndCreateInstance <T>(string code)
 {
     using (var provider = CreateProvider())
     {
         var result = Compile(code, provider);
         var dynamicImplementation = TypeExtractor.RetreiveSubTypesFromAssembly(typeof(T), result.CompiledAssembly).FirstOrDefault();
         if (dynamicImplementation.IsNull())
         {
             throw new StardustCoreException("Not able to locate implementation");
         }
         return(ActivatorFactory.Activator.Activate <T>(dynamicImplementation));
     }
 }
Esempio n. 2
0
        private static Type FindType(Type typeToFind, Assembly module, string className)
        {
            var types = TypeExtractor.RetreiveSubTypesFromAssembly(typeToFind, module);

            if (className.ContainsCharacters())
            {
                types = from t in types
                        where t.FullName == className
                        select t;
            }
            var type = types.FirstOrDefault();

            if (type.IsNull())
            {
                throw new StardustCoreException(NoTypeFoundMessage.FormatString(typeToFind.FullName));
            }
            return(type);
        }