src/Misc/EFTools/DesignXmlCore/Common/SafeWindowTarget.cs
/// <summary>
///     Replaces the WindowTarget for all child controls of the specified collection.
/// </summary>
/// <param name="serviceProvider">The ServiceProvider.</param>
/// <param name="controls">The collection of controls to recurse through and replace their target.</param>
/// <param name="checkControlAdded">
///     If true, in Debug builds, this will assert that any controls
///     added after this call must have their WindowTarget replaced as well.
/// </param>
Replaces the WindowTarget for all child controls of the specified collection.
Replaces the WindowTarget for all child controls of the specified collection .
internal static void ReplaceWindowTargetRecursive(IServiceProvider serviceProvider, ICollection controls, bool checkControlAdded)
        {
            foreach (Control c in controls)
            {
                c.WindowTarget = new SafeWindowTarget(serviceProvider, c.WindowTarget);
                if (checkControlAdded)
                {
#if DEBUG
                    c.ControlAdded += OnChildControlAdded;
#endif
                }
                if (c.Controls.Count > 0)
                {
                    ReplaceWindowTargetRecursive(serviceProvider, c.Controls, checkControlAdded);
                }
            }
        }
internal static void ReplaceWindowTargetRecursive ( IServiceProvider serviceProvider , ICollection controls , bool checkControlAdded ) { foreach ( Control c in controls ) { c . WindowTarget = new SafeWindowTarget ( serviceProvider , c . WindowTarget ) ; if ( checkControlAdded ) { if DEBUG c . ControlAdded += OnChildControlAdded ; endif } if ( c . Controls . Count > 0 ) { ReplaceWindowTargetRecursive ( serviceProvider , c . Controls , checkControlAdded ) ; } } }
Replaces the WindowTarget for all child controls of the specified collection.
Replaces the WindowTarget for all child controls of the specified collection .
// For controls added dynamically after form load, we require the derived class to add the SafeWindowTarget.  // In debug mode, attach a ControlAdded handler that asserts that this happens.
serviceProvider
IServiceProvider
None
controls
ICollection
The collection of controls to recurse through and replace their target.
The collection of controls to recurse through and replace their target .
checkControlAdded
bool
If true, in Debug builds, this will assert that any controls
added after this call must have their WindowTarget replaced as well.
If true in Debug builds this will assert that any controls added after this call must have their WindowTarget replaced as well .