Exemple #1
0
        private static Control FindControlByTypeName(
            Control seed,
            string typeFullName,
            bool shallow,
            bool traverse,
            Control branch)
        {
            if (seed == null || string.IsNullOrEmpty(typeFullName))
            {
                return((Control)null);
            }
            Control branch1 = seed is INamingContainer ? seed : seed.NamingContainer;

            if (ReflectionUtils.IsTypeOf((object)branch1, typeFullName, shallow))
            {
                return(branch1);
            }
            Control control1 = (Control)null;
            string  str      = branch != null ? branch.ID ?? "" : "";

            foreach (Control control2 in branch1.Controls)
            {
                if (!str.Equals(control2.ID))
                {
                    if (ReflectionUtils.IsTypeOf((object)control2, typeFullName, shallow))
                    {
                        control1 = control2;
                    }
                    else if (ControlUtils.HasControls(control2))
                    {
                        control1 = ControlUtils.FindChildControl(control2, typeFullName, shallow);
                    }
                    if (control1 != null)
                    {
                        break;
                    }
                }
            }
            if (traverse && control1 == null)
            {
                control1 = ControlUtils.FindControlByTypeName(branch1.NamingContainer, typeFullName, shallow, traverse, branch1);
            }
            return(control1);
        }
Exemple #2
0
        private static Control FindControlByTypeName(Control seed, string typeFullName, bool shallow, bool traverse, Control branch)
        {
            if (seed == null || string.IsNullOrEmpty(typeFullName))
            {
                return(null);
            }

            Control root = (seed is INamingContainer) ? seed : seed.NamingContainer;

            if (ReflectionUtils.IsTypeOf(root, typeFullName, shallow))
            {
                return(root);
            }

            Control found   = null;
            string  exclude = (branch != null) ? branch.ID ?? "" : "";

            foreach (Control control in root.Controls)
            {
                if (!exclude.Equals(control.ID))
                {
                    if (ReflectionUtils.IsTypeOf(control, typeFullName, shallow))
                    {
                        found = control;
                    }
                    else if (ControlUtils.HasControls(control))
                    {
                        found = ControlUtils.FindChildControl(control, typeFullName, shallow);
                    }

                    if (found != null)
                    {
                        break;
                    }
                }
            }

            if (traverse && found == null)
            {
                found = ControlUtils.FindControlByTypeName(root.NamingContainer, typeFullName, shallow, traverse, root);
            }

            return(found);
        }
Exemple #3
0
 public static Control FindControlByTypeName(Control seed, string typeFullName)
 {
     return(ControlUtils.FindControlByTypeName(seed, typeFullName, false, true, (Control)null));
 }
Exemple #4
0
 public static Control FindControl(Control seed, Type type, bool shallow)
 {
     return(ControlUtils.FindControlByTypeName(seed, type.FullName, shallow, true, (Control)null));
 }