Пример #1
0
        public void GenerateAndDisplayCode(Table table)
        {
            SetCodeControlFormatting(applicationSettings);

            // Refresh the primary key relationships.
            table.PrimaryKey = metadataReader.DeterminePrimaryKeys(table);
            table.ForeignKeys = metadataReader.DetermineForeignKeyReferences(table);

            // Show map and domain code preview
            ApplicationPreferences applicationPreferences = GetApplicationPreferences(table, false, applicationSettings);
            var applicationController = new ApplicationController(applicationPreferences, table);
            applicationController.Generate(false);
            mapCodeFastColoredTextBox.Text = applicationController.GeneratedMapCode;
            domainCodeFastColoredTextBox.Text = applicationController.GeneratedDomainCode;
        }
Пример #2
0
 private void Generate(string tableName, ColumnDetails columnDetails)
 {
     var applicationPreferences = GetApplicationPreferences(tableName);
     var applicationController = new ApplicationController(applicationPreferences, columnDetails);
     applicationController.Generate();
 }
Пример #3
0
        private void GenerateAllClicked(object sender, EventArgs e)
        {
            errorLabel.Text = string.Empty;
            if (tablesComboBox.Items == null || tablesComboBox.Items.Count == 0)
            {
                errorLabel.Text = "Please connect to a database to populate the tables first.";
                return;
            }
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                try
                {
                    if(clearCheck.Checked)
                    {
                        ClearOutputDirectory();
                        errorLabel.Text = " Delete all file completed ...";
                    }
                    errorLabel.Text = " Generating ...";

                    var serverType = (ServerType) serverTypeComboBox.SelectedItem;

                    //foreach (object item in tablesComboBox.Items)
                    var metadataReader = MetadataFactory.GetReader(serverType, connStrTextBox.Text);
                    GlobalCache.Instance.MetaDataReader = metadataReader;
                    GlobalCache.Instance.TablePreferences = _tablePreferences;
                    foreach (ApplicationPreferences item in _tablePreferences)
                    {
                        item.FolderPath = folderTextBox.Text;
                        item.AssemblyName = assemblyNameTextBox.Text;
                        item.NameSpace = nameSpaceTextBox.Text;
                        /*string tableName = item.ToString();

                        var columnDetails = metadataReader.GetTableDetails(tableName);
                        Generate(tableName, columnDetails);*/
                        var columnDetails = metadataReader.GetTableDetails(item.TableName);
                        var applicationController = new ApplicationController(item, columnDetails);
                        applicationController.Generate(genMappingCheck.Checked,genClassCheck.Checked);
                    }
                    errorLabel.Text = "Generated all files successfully.";
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
            catch (Exception ex)
            {
                errorLabel.Text = ex.Message;
            }
        }
Пример #4
0
Файл: App.cs Проект: palfrey/nmg
 private void Generate(Table table, bool generateAll, ApplicationSettings appSettings)
 {
     ApplicationPreferences applicationPreferences = GetApplicationPreferences(table, generateAll, appSettings);
     var applicationController = new ApplicationController(applicationPreferences, table);
     applicationController.Generate();
 }