CreateSubBuilder() private method

private CreateSubBuilder ( string tagid, IDictionary atts, Type childType, System.Web.UI.TemplateParser parser, ILocation location ) : ControlBuilder
tagid string
atts IDictionary
childType Type
parser System.Web.UI.TemplateParser
location ILocation
return ControlBuilder
Example #1
0
        internal virtual ControlBuilder CreateSubBuilder(string tagid,
                                                         IDictionary atts,
                                                         Type childType,
                                                         TemplateParser parser,
                                                         ILocation location)
        {
            ControlBuilder childBuilder = null;

            if (childrenAsProperties)
            {
                if (defaultPropertyBuilder == null)
                {
                    childBuilder = CreatePropertyBuilder(tagid, parser, atts);
                }
                else
                {
                    if (String.Compare(defaultPropertyBuilder.TagName, tagid, true, Helpers.InvariantCulture) == 0)
                    {
                        // The child tag is the same what our default property name. Act as if there was
                        // no default property builder, or otherwise we'll end up with invalid nested
                        // builder call.
                        defaultPropertyBuilder = null;
                        childBuilder           = CreatePropertyBuilder(tagid, parser, atts);
                    }
                    else
                    {
                        Type         ct   = ControlType;
                        MemberInfo[] mems = ct != null?ct.GetMember(tagid, MemberTypes.Property, FlagsNoCase) : null;

                        PropertyInfo prop = mems != null && mems.Length > 0 ? mems [0] as PropertyInfo : null;

                        if (prop != null && typeof(ITemplate).IsAssignableFrom(prop.PropertyType))
                        {
                            childBuilder           = CreatePropertyBuilder(tagid, parser, atts);
                            defaultPropertyBuilder = null;
                        }
                        else
                        {
                            childBuilder = defaultPropertyBuilder.CreateSubBuilder(tagid, atts, null, parser, location);
                        }
                    }
                }

                return(childBuilder);
            }

            if (String.Compare(tagName, tagid, true, Helpers.InvariantCulture) == 0)
            {
                return(null);
            }

            childType = GetChildControlType(tagid, atts);
            if (childType == null)
            {
                return(null);
            }

            childBuilder = CreateBuilderFromType(parser, this, childType, tagid, id, atts,
                                                 location.BeginLine, location.Filename);

            return(childBuilder);
        }