Esempio n. 1
0
        private void InitializeServerDropdown(ComboBox comboBox, PermissableDefaults permissableDefault, ExternalDatabaseServer[] allServers)
        {
            comboBox.Items.Clear();

            var currentDefault = defaults.GetDefaultFor(permissableDefault);
            var patcher        = permissableDefault.ToTier2DatabaseType();

            var toAdd = allServers;

            if (patcher != null) //we expect an explicit type e.g. a HIC.Logging.Database
            {
                var compatibles = Activator.RepositoryLocator.CatalogueRepository.GetAllObjects <ExternalDatabaseServer>().Where(s => s.WasCreatedBy(patcher)).ToArray();

                if (currentDefault == null || compatibles.Contains(currentDefault)) //if there is not yet a default or the existing default is of the correct type
                {
                    toAdd = compatibles;                                            //then we can go ahead and use the restricted type
                }
                //otherwise what we have is a default of the wrong server type! eep.
            }

            comboBox.Items.AddRange(toAdd);

            //select the server
            if (currentDefault != null)
            {
                comboBox.SelectedItem = comboBox.Items.Cast <ExternalDatabaseServer>().Single(s => s.ID == currentDefault.ID);
            }
        }
 public ExecuteCommandCreateNewExternalDatabaseServer(IBasicActivateItems activator, PermissableDefaults defaultToSet, DiscoveredDatabase toCreate)
     : this(activator, defaultToSet == PermissableDefaults.None ? null : defaultToSet.ToTier2DatabaseType(), defaultToSet)
 {
     _database = toCreate;
 }