public void Execute(HbmCompilerConsoleProgramArgs arguments, Action<string> writelog = null) {
     writelog = writelog ?? (s => { });
     var types = GetTypes(arguments, writelog);
     var compiler = new HbmCompiler();
     foreach (var type in types) {
         var outdir = GetOutDir(type, arguments);
         compiler.Execute(type, outdir, writelog);
     }
 }
        private IEnumerable<Type> GetTypes(HbmCompilerConsoleProgramArgs arguments, Action<string> writelog) {
            ResolveEventHandler r = (s, a) => Assembly.LoadFrom(Path.Combine(arguments.Root, a.Name + ".dll"));
            try {
                AppDomain.CurrentDomain.AssemblyResolve+=r;

                var assemblynames = arguments.Assemblies.split();
                foreach (var assemblyname in assemblynames) {
                    var path = Path.Combine(arguments.Root, assemblyname + ".dll");
                    var assembly = ReflectionExtensions.LoadAssemblyFromFile(path);
                    foreach (var type in assembly.GetTypes()) {
                        if (typeof (PersistenceModel).IsAssignableFrom(type)) {
                            yield return type;
                        }
                    }
                }
            }finally {
                AppDomain.CurrentDomain.AssemblyResolve-=r;
            }
        }
 private string GetOutDir(Type type, HbmCompilerConsoleProgramArgs arguments) {
     return Path.Combine(arguments.OutDir, type.FullName.Replace(".", "_"));
 }