private static Control[] ParseControlsInternalHelper(DesignTimeParseData data, bool returnFirst)
        {
            TemplateParser parser = new PageParser {
                FInDesigner  = true,
                DesignerHost = data.DesignerHost,
                DesignTimeDataBindHandler = data.DataBindingHandler,
                Text = data.ParseText
            };

            parser.Parse();
            ArrayList list        = new ArrayList();
            ArrayList subBuilders = parser.RootBuilder.SubBuilders;

            if (subBuilders != null)
            {
                IEnumerator enumerator = subBuilders.GetEnumerator();
                for (int i = 0; enumerator.MoveNext(); i++)
                {
                    object current = enumerator.Current;
                    if ((current is ControlBuilder) && !(current is CodeBlockBuilder))
                    {
                        ControlBuilder   builder         = (ControlBuilder)current;
                        IServiceProvider serviceProvider = null;
                        if (data.DesignerHost != null)
                        {
                            serviceProvider = data.DesignerHost;
                        }
                        else
                        {
                            ServiceContainer container = new ServiceContainer();
                            container.AddService(typeof(IFilterResolutionService), new SimpleDesignTimeFilterResolutionService(data.Filter));
                            serviceProvider = container;
                        }
                        builder.SetServiceProvider(serviceProvider);
                        try
                        {
                            Control control = (Control)builder.BuildObject(data.ShouldApplyTheme);
                            list.Add(control);
                        }
                        finally
                        {
                            builder.SetServiceProvider(null);
                        }
                        if (!returnFirst)
                        {
                            continue;
                        }
                        break;
                    }
                    if (!returnFirst && (current is string))
                    {
                        LiteralControl control2 = new LiteralControl(current.ToString());
                        list.Add(control2);
                    }
                }
            }
            data.SetUserControlRegisterEntries(parser.UserControlRegisterEntries, parser.TagRegisterEntries);
            return((Control[])list.ToArray(typeof(Control)));
        }
        private static Control[] ParseControlsInternalHelper(DesignTimeParseData data, bool returnFirst) {
            TemplateParser parser = new PageParser();
            parser.FInDesigner = true;
            parser.DesignerHost = data.DesignerHost;
            parser.DesignTimeDataBindHandler = data.DataBindingHandler;
            parser.Text = data.ParseText;
            parser.Parse();

            ArrayList parsedControls = new ArrayList();
            ArrayList subBuilders = parser.RootBuilder.SubBuilders;

            if (subBuilders != null) {
                // Look for the first control builder
                IEnumerator en = subBuilders.GetEnumerator();

                for (int i = 0; en.MoveNext(); i++) {
                    object cur = en.Current;

                    if ((cur is ControlBuilder) && !(cur is CodeBlockBuilder)) {
                        // Instantiate the control
                        ControlBuilder controlBuilder = (ControlBuilder)cur;

                        System.Diagnostics.Debug.Assert(controlBuilder.CurrentFilterResolutionService == null);

                        IServiceProvider builderServiceProvider = null;

                        // If there's a designer host, use it as the service provider
                        if (data.DesignerHost != null) {
                            builderServiceProvider = data.DesignerHost;
                        }
                        // If it doesn't exist, use a default ---- filter resolution service
                        else {
                            ServiceContainer serviceContainer = new ServiceContainer();
                            serviceContainer.AddService(typeof(IFilterResolutionService), new SimpleDesignTimeFilterResolutionService(data.Filter));
                            builderServiceProvider = serviceContainer;
                        }

                        controlBuilder.SetServiceProvider(builderServiceProvider);
                        try {
                            Control control = (Control)controlBuilder.BuildObject(data.ShouldApplyTheme);
                            parsedControls.Add(control);
                        }
                        finally {
                            controlBuilder.SetServiceProvider(null);
                        }
                        if (returnFirst) {
                            break;
                        }
                    }
                        // To preserve backwards compatibility, we don't add LiteralControls
                        // to the control collection when parsing for a single control
                    else if (!returnFirst && (cur is string)) {
                        LiteralControl literalControl = new LiteralControl(cur.ToString());
                        parsedControls.Add(literalControl);
                    }
                }
            }

            data.SetUserControlRegisterEntries(parser.UserControlRegisterEntries, parser.TagRegisterEntries);

            return (Control[])parsedControls.ToArray(typeof(Control));
        }
        private static Control[] ParseControlsInternalHelper(DesignTimeParseData data, bool returnFirst)
        {
            TemplateParser parser = new PageParser();

            parser.FInDesigner  = true;
            parser.DesignerHost = data.DesignerHost;
            parser.DesignTimeDataBindHandler = data.DataBindingHandler;
            parser.Text = data.ParseText;
            parser.Parse();

            ArrayList parsedControls = new ArrayList();
            ArrayList subBuilders    = parser.RootBuilder.SubBuilders;

            if (subBuilders != null)
            {
                // Look for the first control builder
                IEnumerator en = subBuilders.GetEnumerator();

                for (int i = 0; en.MoveNext(); i++)
                {
                    object cur = en.Current;

                    if ((cur is ControlBuilder) && !(cur is CodeBlockBuilder))
                    {
                        // Instantiate the control
                        ControlBuilder controlBuilder = (ControlBuilder)cur;

                        System.Diagnostics.Debug.Assert(controlBuilder.CurrentFilterResolutionService == null);

                        IServiceProvider builderServiceProvider = null;

                        // If there's a designer host, use it as the service provider
                        if (data.DesignerHost != null)
                        {
                            builderServiceProvider = data.DesignerHost;
                        }
                        // If it doesn't exist, use a default ---- filter resolution service
                        else
                        {
                            ServiceContainer serviceContainer = new ServiceContainer();
                            serviceContainer.AddService(typeof(IFilterResolutionService), new SimpleDesignTimeFilterResolutionService(data.Filter));
                            builderServiceProvider = serviceContainer;
                        }

                        controlBuilder.SetServiceProvider(builderServiceProvider);
                        try {
                            Control control = (Control)controlBuilder.BuildObject(data.ShouldApplyTheme);
                            parsedControls.Add(control);
                        }
                        finally {
                            controlBuilder.SetServiceProvider(null);
                        }
                        if (returnFirst)
                        {
                            break;
                        }
                    }
                    // To preserve backwards compatibility, we don't add LiteralControls
                    // to the control collection when parsing for a single control
                    else if (!returnFirst && (cur is string))
                    {
                        LiteralControl literalControl = new LiteralControl(cur.ToString());
                        parsedControls.Add(literalControl);
                    }
                }
            }

            data.SetUserControlRegisterEntries(parser.UserControlRegisterEntries, parser.TagRegisterEntries);

            return((Control[])parsedControls.ToArray(typeof(Control)));
        }