protected static void TransferListUniquePart <T>(List <T> sourceList, List <T> destinationList)
 {
     for (int index = 0; index < sourceList.Count; ++index)
     {
         CommandBaseConverter.TransferListUniquePart <T>(sourceList[index], destinationList);
     }
 }
        public static List <IComponent> DiscoverCommandsSources(List <IComponent> list)
        {
            List <IComponent> destinationList = new List <IComponent>(1);

            for (int index = 0; index < list.Count; ++index)
            {
                List <IComponent> sourceList = CommandBaseConverter.DiscoverCommandsSources(list[index]);
                if (sourceList != null && sourceList.Count > 0)
                {
                    CommandBaseConverter.TransferListUniquePart <IComponent>(sourceList, destinationList);
                }
            }
            if (destinationList.Count > 0)
            {
                return(destinationList);
            }
            return((List <IComponent>)null);
        }
        public static List <IComponent> DiscoverCommandsSources(IComponent source)
        {
            if (source == null)
            {
                return((List <IComponent>)null);
            }
            List <IComponent> destinationList = new List <IComponent>(1);

            if (CommandBaseConverter.DiscoverCommands(source) != null)
            {
                CommandBaseConverter.TransferListUniquePart <IComponent>(source, destinationList);
            }
            if (source is RadControl)
            {
                RootRadElement rootElement = (source as RadControl).RootElement;
                if (rootElement != null && rootElement.Children.Count > 0)
                {
                    for (int index = 0; index < rootElement.Children.Count; ++index)
                    {
                        IComponent child = rootElement.Children[index] as IComponent;
                        if (child != null && child is IItemsOwner)
                        {
                            List <IComponent> sourceList = CommandBaseConverter.DiscoverCommandsSources(child);
                            if (destinationList != null)
                            {
                                CommandBaseConverter.TransferListUniquePart <IComponent>(sourceList, destinationList);
                            }
                        }
                    }
                }
            }
            if (destinationList.Count > 0)
            {
                return(destinationList);
            }
            return((List <IComponent>)null);
        }
        public static List <IComponent> DiscoverCommandsContexts(IComponent source)
        {
            if (source == null)
            {
                return((List <IComponent>)null);
            }
            List <IComponent> destinationList = new List <IComponent>(1);

            if (typeof(RadControl).IsAssignableFrom(source.GetType()) || typeof(RadItem).IsAssignableFrom(source.GetType()))
            {
                CommandBaseConverter.TransferListUniquePart <IComponent>(source, destinationList);
            }
            if (source is RadControl)
            {
                RootRadElement rootElement = (source as RadControl).RootElement;
                if (rootElement != null && rootElement.Children.Count > 0)
                {
                    foreach (RadElement child in rootElement.Children)
                    {
                        IComponent source1 = child as IComponent;
                        if (source1 != null && child is IItemsOwner)
                        {
                            List <IComponent> sourceList = CommandBaseConverter.DiscoverCommandsContexts(source1);
                            if (destinationList != null)
                            {
                                CommandBaseConverter.TransferListUniquePart <IComponent>(sourceList, destinationList);
                            }
                        }
                    }
                }
            }
            if (destinationList.Count > 0)
            {
                return(destinationList);
            }
            return((List <IComponent>)null);
        }