protected override void BuildSourceDataTreeFromBuilder(ControlBuilder builder, bool fInTemplate, bool topLevelControlInTemplate, PropertyEntry pse) { if (!(builder is CodeBlockBuilder)) { bool fTemplate = builder is TemplateBuilder; bool flag2 = builder == this._themeParser.RootBuilder; bool fControlSkin = (!fInTemplate && !fTemplate) && topLevelControlInTemplate; this._controlCount++; builder.ID = "__control" + this._controlCount.ToString(NumberFormatInfo.InvariantInfo); builder.IsGeneratedID = true; if (fControlSkin && !(builder is DataBoundLiteralControlBuilder)) { Type controlType = builder.ControlType; string skinID = builder.SkinID; object key = PageTheme.CreateSkinKey(builder.ControlType, skinID); if (this._controlSkinTypeNameCollection.Contains(key)) { if (string.IsNullOrEmpty(skinID)) { throw new HttpParseException(System.Web.SR.GetString("Page_theme_default_theme_already_defined", new object[] { builder.ControlType.FullName }), null, builder.VirtualPath, null, builder.Line); } throw new HttpParseException(System.Web.SR.GetString("Page_theme_skinID_already_defined", new object[] { skinID }), null, builder.VirtualPath, null, builder.Line); } this._controlSkinTypeNameCollection.Add(key, true); this._controlSkinBuilderEntryList.Add(new ControlSkinBuilderEntry(builder, skinID)); } if (builder.SubBuilders != null) { foreach (object obj3 in builder.SubBuilders) { if (obj3 is ControlBuilder) { bool flag4 = fTemplate && typeof(Control).IsAssignableFrom(((ControlBuilder)obj3).ControlType); this.BuildSourceDataTreeFromBuilder((ControlBuilder)obj3, fInTemplate, flag4, null); } } } foreach (TemplatePropertyEntry entry in builder.TemplatePropertyEntries) { this.BuildSourceDataTreeFromBuilder(entry.Builder, true, false, entry); } foreach (ComplexPropertyEntry entry2 in builder.ComplexPropertyEntries) { if (!(entry2.Builder is StringPropertyBuilder)) { this.BuildSourceDataTreeFromBuilder(entry2.Builder, fInTemplate, false, entry2); } } if (!flag2) { base.BuildBuildMethod(builder, fTemplate, fInTemplate, topLevelControlInTemplate, pse, fControlSkin); } if (!fControlSkin && builder.HasAspCode) { base.BuildRenderMethod(builder, fTemplate); } base.BuildExtractMethod(builder); base.BuildPropertyBindingMethod(builder, fControlSkin); } }
protected override void BuildSourceDataTreeFromBuilder(ControlBuilder builder, bool fInTemplate, bool topLevelControlInTemplate, PropertyEntry pse) { // Don't do anything for code blocks if (builder is CodeBlockBuilder) { return; } // Is the current builder for a template? bool fTemplate = (builder is TemplateBuilder); // Is the current builder the root builder? bool fRootBuilder = (builder == _themeParser.RootBuilder); // Is this a control theme? bool fControlSkin = !fInTemplate && !fTemplate && topLevelControlInTemplate; // Ignore the ID attribute, always auto generate ID. _controlCount++; builder.ID = "__control" + _controlCount.ToString(NumberFormatInfo.InvariantInfo); builder.IsGeneratedID = true; // Check for the SkinID property. if (fControlSkin && !(builder is DataBoundLiteralControlBuilder)) { Type ctrlType = builder.ControlType; Debug.Assert(typeof(Control).IsAssignableFrom(ctrlType)); Debug.Assert(ThemeableAttribute.IsTypeThemeable(ctrlType)); string skinID = builder.SkinID; object skinKey = PageTheme.CreateSkinKey(builder.ControlType, skinID); if (_controlSkinTypeNameCollection.Contains(skinKey)) { if (String.IsNullOrEmpty(skinID)) { throw new HttpParseException(SR.GetString(SR.Page_theme_default_theme_already_defined, builder.ControlType.FullName), null, builder.VirtualPath, null, builder.Line); } else { throw new HttpParseException(SR.GetString(SR.Page_theme_skinID_already_defined, skinID), null, builder.VirtualPath, null, builder.Line); } } _controlSkinTypeNameCollection.Add(skinKey, true); _controlSkinBuilderEntryList.Add(new ControlSkinBuilderEntry(builder, skinID)); } // Process the children // only root builders and template builders are processed. if (builder.SubBuilders != null) { foreach (object child in builder.SubBuilders) { if (child is ControlBuilder) { bool isTopLevelCtrlInTemplate = fTemplate && typeof(Control).IsAssignableFrom(((ControlBuilder)child).ControlType); BuildSourceDataTreeFromBuilder((ControlBuilder)child, fInTemplate, isTopLevelCtrlInTemplate, null); } } } foreach (TemplatePropertyEntry entry in builder.TemplatePropertyEntries) { BuildSourceDataTreeFromBuilder(((TemplatePropertyEntry)entry).Builder, true, false /*topLevelControlInTemplate*/, entry); } foreach (ComplexPropertyEntry entry in builder.ComplexPropertyEntries) { if (!(entry.Builder is StringPropertyBuilder)) { BuildSourceDataTreeFromBuilder(((ComplexPropertyEntry)entry).Builder, fInTemplate, false /*topLevelControlInTemplate*/, entry); } } // Build a Build method for the control // fControlSkin indicates whether the method is a theme build method. if (!fRootBuilder) { BuildBuildMethod(builder, fTemplate, fInTemplate, topLevelControlInTemplate, pse, fControlSkin); } // Build a Render method for the control, unless it has no code if (!fControlSkin && builder.HasAspCode) { BuildRenderMethod(builder, fTemplate); } // Build a method to extract values from the template BuildExtractMethod(builder); // Build a property binding method for the control BuildPropertyBindingMethod(builder, fControlSkin); }