Esempio n. 1
0
        protected override void CreateChildControls()
        {
            try
            {
                //CHECK IF PAGE IS IN DISPLAY MODE.
                if (UtilityManager.CheckIsDisplayMode() == false)
                {
                    Dictionary <String, String> customProperties = new Dictionary <String, String>();

                    customProperties.Add("CurrentCodeId", this.CurrentCodeId);
                    customProperties.Add("ContainerDivId", this.ContainerDivId);
                    customProperties.Add("CodeLibraryClientName", this.CodeLibraryClientName);
                    customProperties.Add("CodeCommonClientName", this.CodeCommonClientName);
                    customProperties.Add("CodeFolderClientName", this.CodeFolderClientName);
                    customProperties.Add("EntryPointClientFunction", this.EntryPointClientFunction);
                    customProperties.Add("JsonData", this.JsonData);

                    customProperties.Add("RenderAsynchronousMode", this.RenderAsynchronousMode.ToString());
                    customProperties.Add("CodeLibraryServerName", this.CodeLibraryServerName);
                    customProperties.Add("CodeCommonServerName", this.CodeCommonServerName);
                    customProperties.Add("CodeFolderServerName", this.CodeFolderServerName);
                    customProperties.Add("FileNameCS", this.FileNameCS);
                    customProperties.Add("ClassNameCS", this.ClassNameCS);
                    customProperties.Add("MethodNameCS", this.MethodNameCS);

                    //TO-DO
                    //var propertyInfos = this.GetType().GetRuntimeProperties();
                    //foreach (var propertyInfo in propertyInfos)
                    //{
                    //	if (this.GetType().GetRuntimeProperty(propertyInfo.Name).CustomAttributes
                    //}

                    this.Controls.Add(UtilityManager.CreateDebugPanel(customProperties));
                    return;
                }
                //CHECK IF CURRENT CODE ID IS IN CORRECT FORMAT
                if (UtilityManager.CheckCurrentCodeId(this.CurrentCodeId) == false)
                {
                    this.Controls.Add(ErrorManager.ErrorControlCurrentCodeId);
                    return;
                }
                //CHECK IF CONTAINER DIV ID IS IN CORRECT FORMAT
                if (UtilityManager.CheckContainerDivId(this.ContainerDivId) == false)
                {
                    this.Controls.Add(ErrorManager.ErrorControlContainerDivId);
                    return;
                }
                else
                {
                    HtmlGenericControl containerDiv = new HtmlGenericControl("div");
                    containerDiv.Attributes.Add("id", this.ContainerDivId);
                    //containerDiv.Style.Add(HtmlTextWriterStyle.Display, "none");
                    this.Controls.Add(containerDiv);
                }

                CodeManager codeManager = new CodeManager();
                codeManager.CurrentCodeId            = this.CurrentCodeId;
                codeManager.ContainerDivId           = this.ContainerDivId;
                codeManager.CodeLibraryClientName    = this.CodeLibraryClientName;
                codeManager.CodeCommonClientName     = this.CodeCommonClientName;
                codeManager.CodeFolderClientName     = this.CodeFolderClientName;
                codeManager.EntryPointClientFunction = this.EntryPointClientFunction;
                codeManager.JsonData = this.JsonData;

                codeManager.RenderAsynchronousMode = this.RenderAsynchronousMode;
                codeManager.CodeLibraryServerName  = this.CodeLibraryServerName;
                codeManager.CodeCommonServerName   = this.CodeCommonServerName;
                codeManager.CodeFolderServerName   = this.CodeFolderServerName;
                codeManager.FileNameCS             = this.FileNameCS;
                codeManager.ClassNameCS            = this.ClassNameCS;
                codeManager.MethodNameCS           = this.MethodNameCS;

                codeManager.SharePointPage = this.Page;

                //((HtmlGenericControl)this.Controls[0]).Style[HtmlTextWriterStyle.BackgroundColor] = "Red";
                ((HtmlGenericControl)this.Controls[0]).InnerHtml = codeManager.RenderServerCode();
            }
            catch (Exception ex)
            {
                HtmlGenericControl errorDiv = new HtmlGenericControl("div");
                errorDiv.InnerHtml = "CreateChildControls: " + ex.ToString();
                this.Controls.Add(errorDiv);
            }
        }