private void btnGeraArquivos_Click(object sender, RoutedEventArgs e) { ListaComaAsTabelas(); _tipoDeBanco = RetornaTipoDeBancoDeDados(); _geraEntidades = new GeraEntidades(_tipoDeBanco); if (_listacomastabelas.Count() > 0) { var openFileDialog = new OpenFileDialog(); openFileDialog.DefaultExt = ".csproj"; openFileDialog.Filter = "csproj files (*.csproj)|*.csproj"; var result = openFileDialog.ShowDialog(); if (result == true) { _caminhoDoArquivoProj = openFileDialog.FileName; _namesPace = openFileDialog.SafeFileName; _caminho = _caminhoDoArquivoProj.Substring(0, _caminhoDoArquivoProj.Length - _namesPace.Length); _namesPace = _namesPace.Substring(0, _namesPace.Length - 7); SetaPropriedadesDeGeraEntidade(); _lazy = chkLazy.SelectedIndex == 0; if (!string.IsNullOrWhiteSpace(_caminho)) { var trd = new Thread(GeraOsArquivos) {IsBackground = true}; trd.Start(); } GeracaoDaClasseNHibernateHelp(); var moverArquivos = new MoverArquivos(); moverArquivos.CopiaAsDLLNHibernate(_caminho); var referenciaAsDllnHiberante = new ReferenciaAsDLLNHiberante(); referenciaAsDllnHiberante.FazReferenciaAsDllNHibernate(_caminhoDoArquivoProj); } } else { MessageBox.Show("É necessário uma ou mais tabelas.", "Atenção!", MessageBoxButton.OK, MessageBoxImage.Information); } }
public void CopiaAsDLLNHibernate(string caminho) { const string dllNHibernate = @"\DLL NHibernate"; String appStartPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); string[] files = System.IO.Directory.GetFiles(appStartPath+dllNHibernate); GeraEntidades geraEntidades = new GeraEntidades(TipoDeBancoDados.Sqlserver); geraEntidades.CriaDiretorio(caminho+dllNHibernate); foreach (string file in files) { string fileName = System.IO.Path.GetFileName(file); string destFile = System.IO.Path.Combine(caminho + dllNHibernate, fileName); System.IO.File.Copy(file, destFile, true); } }