src/Misc/EFTools/XmlCore/UI/Selection.cs
/// <summary>
///     Selection helper method.  This sets itemToSelect into the selection.
///     Any existing items are deselected.
/// </summary>
/// <param name="context">The editing context to apply this selection change to.</param>
/// <param name="itemToSelect">The item to select.</param>
/// <returns>A Selection object that contains the new selection.</returns>
/// <exception cref="ArgumentNullException">If context or itemToSelect is null.</exception>
Selection helper method.  This sets itemToSelect into the selection.
Any existing items are deselected.
Selection helper method . This sets itemToSelect into the selection . Any existing items are deselected .
internal static T SelectOnly<T>(EditingContext context, EFObject itemToSelect) where T : Selection
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (itemToSelect == null)
            {
                throw new ArgumentNullException("itemToSelect");
            }
            var existing = context.Items.GetValue<T>();
            if (existing.PrimarySelection == itemToSelect)
            {
                var en = existing.SelectedObjects.GetEnumerator();
                en.MoveNext();
                if (!en.MoveNext())
                {
                    return existing;
                }
            }
            var selection = Activator.CreateInstance<T>();
            selection.SetSelectedObjects(itemToSelect);
            context.Items.SetValue(selection);
            return selection;
        }
internal static T SelectOnly < T > ( EditingContext context , EFObject itemToSelect ) where T : Selection { if ( context == null ) { throw new ArgumentNullException ( " " ) ; } if ( itemToSelect == null ) { throw new ArgumentNullException ( " " ) ; } var existing = context . Items . GetValue < T > ( ) ; if ( existing . PrimarySelection == itemToSelect ) { var en = existing . SelectedObjects . GetEnumerator ( ) ; en . MoveNext ( ) ; if ( ! en . MoveNext ( ) ) { return existing ; } } var selection = Activator . CreateInstance < T > ( ) ; selection . SetSelectedObjects ( itemToSelect ) ; context . Items . SetValue ( selection ) ; return selection ; }
Selection helper method.
Selection helper method .
// Check to see if only this object is selected.  If so, bail.
A Selection object that contains the new selection.
A Selection object that contains the new selection .
If context or itemToSelect is null.
If context or itemToSelect is null .
context
EditingContext
The editing context to apply this selection change to.
The editing context to apply this selection change to .
itemToSelect
EFObject
The item to select.
The item to select .