public override string GetDesignTimeHtml()
 {
     AdRotator viewControl = (AdRotator) base.ViewControl;
     StringWriter writer = new StringWriter(CultureInfo.CurrentCulture);
     DesignTimeHtmlTextWriter writer2 = new DesignTimeHtmlTextWriter(writer);
     HyperLink link = new HyperLink {
         ID = viewControl.ID,
         NavigateUrl = "",
         Target = viewControl.Target,
         AccessKey = viewControl.AccessKey,
         Enabled = viewControl.Enabled,
         TabIndex = viewControl.TabIndex
     };
     link.Style.Value = viewControl.Style.Value;
     link.RenderBeginTag(writer2);
     Image image = new Image();
     image.ApplyStyle(viewControl.ControlStyle);
     image.SetDesignMode();
     image.ImageUrl = "";
     image.AlternateText = viewControl.ID;
     image.ToolTip = viewControl.ToolTip;
     image.RenderControl(writer2);
     link.RenderEndTag(writer2);
     return writer.ToString();
 }
 public ViewRendering GetViewRendering(Control control)
 {
     string str;
     DesignerRegionCollection regions;
     try
     {
         this._partViewRendering = ControlDesigner.GetViewRendering(control);
         regions = this._partViewRendering.Regions;
         WebPart part = control as WebPart;
         if (part == null)
         {
             part = new DesignerGenericWebPart(PartDesigner.GetViewControl(control));
         }
         StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);
         this.RenderWebPart(new DesignTimeHtmlTextWriter(writer), (WebPart) PartDesigner.GetViewControl(part));
         str = writer.ToString();
     }
     catch (Exception exception)
     {
         str = ControlDesigner.CreateErrorDesignTimeHtml(System.Design.SR.GetString("ControlDesigner_UnhandledException"), exception, control);
         regions = new DesignerRegionCollection();
     }
     StringWriter writer2 = new StringWriter(CultureInfo.InvariantCulture);
     DesignTimeHtmlTextWriter writer3 = new DesignTimeHtmlTextWriter(writer2);
     bool flag = base.Zone.LayoutOrientation == Orientation.Horizontal;
     if (flag)
     {
         writer3.AddStyleAttribute("display", "inline-block");
         writer3.AddStyleAttribute(HtmlTextWriterStyle.Height, "100%");
         writer3.RenderBeginTag(HtmlTextWriterTag.Span);
     }
     writer3.Write(str);
     if (flag)
     {
         writer3.RenderEndTag();
     }
     return new ViewRendering(writer2.ToString(), regions);
 }
 public override string GetDesignTimeHtml()
 {
     if (base.Component.Site != null)
     {
         IWebApplication application = (IWebApplication) base.Component.Site.GetService(typeof(IWebApplication));
         IDesignerHost host = (IDesignerHost) base.Component.Site.GetService(typeof(IDesignerHost));
         if (((application != null) && (host != null)) && (base.RootDesigner.ReferenceManager != null))
         {
             IUserControlDesignerAccessor component = (IUserControlDesignerAccessor) base.Component;
             string[] strArray = component.TagName.Split(new char[] { ':' });
             string userControlPath = base.RootDesigner.ReferenceManager.GetUserControlPath(strArray[0], strArray[1]);
             userControlPath = this.MakeAppRelativePath(userControlPath);
             IThemeResolutionService themeService = (IThemeResolutionService) base.Component.Site.GetService(typeof(IThemeResolutionService));
             string key = this.GenerateUserControlCacheKey(userControlPath, themeService);
             if (!string.IsNullOrEmpty(userControlPath))
             {
                 string b = null;
                 string second = string.Empty;
                 bool flag = false;
                 IDictionary dictionary = _antiRecursionDictionary;
                 IDictionaryService service = (IDictionaryService) application.GetService(typeof(IDictionaryService));
                 if (service != null)
                 {
                     dictionary = (IDictionary) service.GetValue("__aspnetUserControlCache");
                     if (dictionary == null)
                     {
                         dictionary = new HybridDictionary();
                         service.SetValue("__aspnetUserControlCache", dictionary);
                     }
                     Pair pair = (Pair) dictionary[key];
                     if (pair != null)
                     {
                         b = (string) pair.First;
                         second = (string) pair.Second;
                         flag = second.Contains("mvwres:");
                     }
                     else
                     {
                         flag = true;
                     }
                 }
                 IDocumentProjectItem projectItemFromUrl = application.GetProjectItemFromUrl(userControlPath) as IDocumentProjectItem;
                 if (projectItemFromUrl != null)
                 {
                     this._userControlFound = true;
                     string contents = new StreamReader(projectItemFromUrl.GetContents()).ReadToEnd();
                     string a = null;
                     if (!flag)
                     {
                         a = this.GenerateUserControlHashCode(contents, themeService);
                         flag = !string.Equals(a, b, StringComparison.OrdinalIgnoreCase) || contents.Contains(".ascx");
                     }
                     if (flag)
                     {
                         if (_antiRecursionDictionary.Contains(key))
                         {
                             return base.CreateErrorDesignTimeHtml(System.Design.SR.GetString("UserControlDesigner_CyclicError"));
                         }
                         _antiRecursionDictionary[key] = base.CreateErrorDesignTimeHtml(System.Design.SR.GetString("UserControlDesigner_CyclicError"));
                         second = string.Empty;
                         Pair pair2 = new Pair();
                         if (a == null)
                         {
                             a = this.GenerateUserControlHashCode(contents, themeService);
                         }
                         pair2.First = a;
                         pair2.Second = second;
                         dictionary[key] = pair2;
                         UserControl child = (UserControl) base.Component;
                         Page rootComponent = new Page();
                         try
                         {
                             rootComponent.Controls.Add(child);
                             IDesignerHost host2 = new UserControlDesignerHost(host, rootComponent, userControlPath);
                             if (!string.IsNullOrEmpty(contents))
                             {
                                 List<Triplet> userControlRegisterEntries = new List<Triplet>();
                                 Control[] controlArray = ControlSerializer.DeserializeControlsInternal(contents, host2, userControlRegisterEntries);
                                 foreach (Control control2 in controlArray)
                                 {
                                     if ((!(control2 is LiteralControl) && !(control2 is DesignerDataBoundLiteralControl)) && !(control2 is DataBoundLiteralControl))
                                     {
                                         if (string.IsNullOrEmpty(control2.ID))
                                         {
                                             throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, System.Design.SR.GetString("UserControlDesigner_MissingID"), new object[] { control2.GetType().Name }));
                                         }
                                         host2.Container.Add(control2);
                                     }
                                     child.Controls.Add(control2);
                                 }
                                 foreach (Triplet triplet in userControlRegisterEntries)
                                 {
                                     string first = (string) triplet.First;
                                     Pair pair3 = (Pair) triplet.Second;
                                     Pair third = (Pair) triplet.Third;
                                     if (pair3 != null)
                                     {
                                         string tagName = (string) pair3.First;
                                         string src = (string) pair3.Second;
                                         ((UserControlDesignerHost) host2).RegisterUserControl(first, tagName, src);
                                     }
                                     else if (third != null)
                                     {
                                         string tagNamespace = (string) third.First;
                                         string assemblyName = (string) third.Second;
                                         ((UserControlDesignerHost) host2).RegisterTagNamespace(first, tagNamespace, assemblyName);
                                     }
                                 }
                                 StringBuilder builder = new StringBuilder();
                                 foreach (Control control3 in controlArray)
                                 {
                                     if (control3 is LiteralControl)
                                     {
                                         builder.Append(((LiteralControl) control3).Text);
                                     }
                                     else if (control3 is DesignerDataBoundLiteralControl)
                                     {
                                         builder.Append(((DesignerDataBoundLiteralControl) control3).Text);
                                     }
                                     else if (control3 is DataBoundLiteralControl)
                                     {
                                         builder.Append(((DataBoundLiteralControl) control3).Text);
                                     }
                                     else if (control3 is HtmlControl)
                                     {
                                         StringWriter writer = new StringWriter(CultureInfo.CurrentCulture);
                                         DesignTimeHtmlTextWriter writer2 = new DesignTimeHtmlTextWriter(writer);
                                         control3.RenderControl(writer2);
                                         builder.Append(writer.GetStringBuilder().ToString());
                                     }
                                     else
                                     {
                                         ViewRendering viewRendering = ((ControlDesigner) host2.GetDesigner(control3)).GetViewRendering();
                                         builder.Append(viewRendering.Content);
                                     }
                                 }
                                 second = builder.ToString();
                             }
                             pair2.Second = second;
                         }
                         catch
                         {
                             dictionary.Remove(key);
                             throw;
                         }
                         finally
                         {
                             _antiRecursionDictionary.Remove(key);
                             child.Controls.Clear();
                             rootComponent.Controls.Remove(child);
                         }
                     }
                 }
                 else
                 {
                     second = base.CreateErrorDesignTimeHtml(System.Design.SR.GetString("UserControlDesigner_NotFound", new object[] { userControlPath }));
                 }
                 if (second.Trim().Length > 0)
                 {
                     return second;
                 }
             }
         }
     }
     return base.CreatePlaceHolderDesignTimeHtml();
 }
 public virtual string GetDesignTimeHtml()
 {
     StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);
     DesignTimeHtmlTextWriter writer2 = new DesignTimeHtmlTextWriter(writer);
     string errorDesignTimeHtml = null;
     bool flag = false;
     bool visible = true;
     System.Web.UI.Control viewControl = null;
     try
     {
         viewControl = this.ViewControl;
         visible = viewControl.Visible;
         if (!visible)
         {
             viewControl.Visible = true;
             flag = !this.UsePreviewControl;
         }
         viewControl.RenderControl(writer2);
         errorDesignTimeHtml = writer.ToString();
     }
     catch (Exception exception)
     {
         errorDesignTimeHtml = this.GetErrorDesignTimeHtml(exception);
     }
     finally
     {
         if (flag)
         {
             viewControl.Visible = visible;
         }
     }
     if ((errorDesignTimeHtml != null) && (errorDesignTimeHtml.Length != 0))
     {
         return errorDesignTimeHtml;
     }
     return this.GetEmptyDesignTimeHtml();
 }