Esempio n. 1
0
        public void Precompile(Action <string> precompileProgressWriter)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();

            foreach (Tuple <Type, IEnumerable <PrecompileAttribute> > applyType in assembly.TypesWithAttribute <PrecompileAttribute>(true).Where(x => !x.Item1.IsAbstract))
            {
                precompileProgressWriter("Precompiling " + applyType.Item1.Name + "\n");

                IPrecompilable instance = (IPrecompilable)Activator.CreateInstance(applyType.Item1);
                instance.Precompile(Compiler);
            }
        }
Esempio n. 2
0
        public static void PrecompileAllFields(object instance, CudaCompiler compiler)
        {
            Type type = instance.GetType();

            foreach (FieldInfo field in type.GetFields())
            {
                if (typeof(IPrecompilable).IsAssignableFrom(field.FieldType))
                {
                    IPrecompilable precompilableField = (IPrecompilable)field.GetValue(instance);
                    Console.WriteLine("Compiling field " + field.Name);
                    precompilableField.Precompile(compiler);
                }
            }
        }