Ejemplo n.º 1
0
        // Set the container name in temporary storage, update the connection string, and fire the event so the EntitySet will know there has been a change
        internal void SelectContainerName(EntityDataSourceContainerNameItem selectedContainer)
        {
            _selectedContainerName = selectedContainer;

            UpdateWizardState();
            OnContainerNameChanged(_selectedContainerName);
        }
Ejemplo n.º 2
0
 // Fires the event to notify that a container has been chosen from the list
 private void OnContainerNameChanged(EntityDataSourceContainerNameItem selectedContainerName)
 {
     if (_containerNameChanged != null)
     {
         _containerNameChanged(this, selectedContainerName);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Find the current container in the current list of containers
        /// </summary>
        /// <param name="containerName">The container name to find</param>
        /// <param name="addIfNotFound">if true, adds the container name to the list if it is not found.</param>
        /// <returns></returns>
        private EntityDataSourceContainerNameItem FindContainerName(string containerName, bool addIfNotFound)
        {
            Debug.Assert(_containerNames != null, "_containerNames have already been initialized and should not be null");

            if (!String.IsNullOrEmpty(containerName))
            {
                EntityDataSourceContainerNameItem containerToSelect = null;
                foreach (EntityDataSourceContainerNameItem containerNameItem in _containerNames)
                {
                    // Ignore case here when searching the list for a matching item, but set the temporary state property to the
                    // correctly-cased version from metadata so that if the user clicks Finish, the correct one will be saved. This
                    // allows some flexibility the designer without preserving an incorrectly-cased value that could cause errors at runtime.
                    if (String.Equals(containerName, containerNameItem.EntityContainerName, StringComparison.OrdinalIgnoreCase))
                    {
                        containerToSelect = containerNameItem;
                    }
                }

                // didn't find a matching container, so just create a placeholder for one using the specified name and add it to the list
                if (containerToSelect == null && addIfNotFound)
                {
                    containerToSelect = new EntityDataSourceContainerNameItem(containerName);
                    _containerNames.Add(containerToSelect);
                }

                Debug.Assert(addIfNotFound == false || containerToSelect != null, "expected a non-null EntityDataSourceContainerNameItem");
                return(containerToSelect);
            }

            return(null);
        }
Ejemplo n.º 4
0
        // Populates the EntitySetName combobox with all of the discoverable EntitySets for the specified container.
        // If the specified entitySetName is not empty, it is added to the list and selected as the initial value
        // containerNameItem may not be backed by a real EntityContainer, in which case there is no way to look up the EntitySet in metadata
        // devnote: This method should not automatically reset EntityTypeFilter and Select because it can be used to load the initial state
        //          for the form, in which case we need to preserve any values that are already set on the data source control.
        private void LoadEntitySetNames(EntityDataSourceContainerNameItem containerNameItem, string entitySetName)
        {
            // If this is a container that we found in the project's metadata, get a list of EntitySets for that container
            if (containerNameItem != null && containerNameItem.EntityContainer != null)
            {
                _entitySetNames = _helper.GetEntitySets(containerNameItem.EntityContainer, false /*sortResults*/);

                // Try to find the specified entityset in list and add it if it isn't there
                _selectedEntitySetName = FindEntitySetName(entitySetName);
            }
            else
            {
                // if this is an unknown container, there is no way to find a list of entitysets from metadata
                // so just create a new list and placeholder for the specified entityset
                _entitySetNames = new List <EntityDataSourceEntitySetNameItem>();
                if (!String.IsNullOrEmpty(entitySetName))
                {
                    _selectedEntitySetName = new EntityDataSourceEntitySetNameItem(entitySetName);
                    _entitySetNames.Add(_selectedEntitySetName);
                }
                else
                {
                    _selectedEntitySetName = null;
                }
            }

            // Sort the list now, after we may have added one above
            _entitySetNames.Sort();

            // Update the controls
            _panel.SetEntitySetNames(_entitySetNames);
            _panel.SetSelectedEntitySetName(_selectedEntitySetName);
        }
Ejemplo n.º 5
0
        // Event handler to process notifications when a DefaultContainerName is selected on the ObjectContext configuration panel
        internal void ContainerNameChangedHandler(object sender, EntityDataSourceContainerNameItem newContainerName)
        {
            // Load the entity sets for this container, don't select anything initially in the list
            LoadEntitySetNames(newContainerName, null);

            // Reset the other controls that depend on the value of EntitySet
            LoadEntityTypeFilters(null, null);
            LoadSelect(String.Empty);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Populates the DefaultContainerName ComboBox with all of the EntityContainers in the loaded metadata
        /// If the specified DefaultContainerName property on the data source control is not empty and 'initialLoad' is true,
        /// it is added to the list and selected in the control
        /// </summary>
        /// <param name="containerName">The container name to find</param>
        /// <param name="initialLoad">if true, this is the initial load so the container name is added to the list if it is not found.</param>
        private void LoadContainerNames(string containerName, bool initialLoad)
        {
            // Get a list of EntityContainers from the metadata in the connection string
            _containerNames = _helper.GetContainerNames(false /*sortResults*/);

            // Try to find the specified container in list
            _selectedContainerName = FindContainerName(containerName, initialLoad /*addIfNotFound*/);

            // Sort the list now, after we may have added a new entry above
            _containerNames.Sort();

            // Update the controls
            _panel.SetContainerNames(_containerNames);
            _panel.SetSelectedContainerName(_selectedContainerName, initialLoad /*initialLoad*/);
        }
 /// <summary>
 /// Expects that selectedContainer is already in the ComboBox list, or should be null
 /// </summary>
 /// <param name="selectedContainer"></param>
 /// <param name="initialLoad">If this is the initial load, we want to suppress events so that the change does
 /// not cause additional work in panels that listen to the container name changed event</param>
 internal void SetSelectedContainerName(EntityDataSourceContainerNameItem selectedContainer, bool initialLoad)
 {
     if (initialLoad)
     {
         _ignoreEvents = true;
     }
     if (selectedContainer == null)
     {
         _containerNameComboBox.SelectedIndex = -1;
     }
     else
     {
         _containerNameComboBox.SelectedItem = selectedContainer;
     }
     _ignoreEvents = false;
 }