public object Clone() { if (!this.IsParsed) { this.Parse(); } GadgetMaster gm; if (MyOffset != null) { gm = new GadgetMaster(this.MyControlFactory, this.RawTag, MyOffset.Clone() as OffsetItem); } else { gm = new GadgetMaster(this.MyControlFactory, this.RawTag); gm.Parse(); } if (gm.HasExternalMessageBundles()) { gm.LoadConsolidatedMessageBundles(this.SerializationExternalMessageBundle); } if (gm.HasExternalTemplateLibraries()) { } //todo - accomodate external templates return(gm); }
/// <summary> /// Given a populated <c>OffsetList</c>, build the controls from the RawTag. /// Make sure you invoke this method, if overridden. /// <para> /// Most cases can be handled by overriding AddControl instead. /// </para> /// </summary> protected virtual void BuildControlTreeFromOffsets() { if (null == MyOffset) { throw new ArgumentException("Offsets must be built prior to loading control tree"); } int i = 0; int markupEnd, markupStart, initialScriptAdjustment = 0; int startAdjustment = 0, endAdjustment = 0; OffsetItem item; string blob; // TODO: Abstract this out for non-hard coding //if (("GadgetRoot" == MyOffset.OffsetKey || "Templates" == MyOffset.OffsetKey //this needs to be addressed as a design flaw // || MyOffset.OffsetKey == this.MyControlFactory.RootElement.OffsetKey) // && MyOffset.Position > 0) if (MyControlFactory.IsRootElement(this) && ((RootElementMaster)this).HasXmlDeclaration) { startAdjustment = MyOffset.Position; endAdjustment = startAdjustment; } if (MyOffset.HasChildList()) { for (i = 0; i < MyOffset.ChildOffsets.Count; i++) { item = MyOffset.ChildOffsets[i]; int nextItemStart = 0; if (i < MyOffset.ChildOffsets.Count - 1) { nextItemStart = MyOffset.ChildOffsets[i + 1].Position; } //markupEnd = item.GetAbsoluteEndPosition(nextItemStart); markupEnd = GetMarkupEndPosition(MyOffset.ChildOffsets, i); if (markupEnd <= 0) { markupEnd = RawTag.Length; } else if (endAdjustment > 0) { markupEnd += endAdjustment; } // GetMarkupEndPosition(MyOffset.ChildOffsets, i); if (0 == i && 0 == item.Position) { markupStart = initialScriptAdjustment; markupEnd = markupEnd - initialScriptAdjustment; } else { markupStart = item.Position + startAdjustment; } blob = RawTag.Substring(markupStart, markupEnd - markupStart); this.AddResolveControlTag(item, blob); } } }