コード例 #1
0
        protected override EditorPartCollection CreateEditorParts() {
            EditorPartCollection editorParts = new EditorPartCollection();

            if (_zoneTemplate != null) {
                // PERF: Instantiate the template into a special control, that does nothing when a child control
                // is added.  This is more performant because the child control is never parented to the temporary
                // control, it's ID is never generated, etc.
                Control container = new NonParentingControl();

                _zoneTemplate.InstantiateIn(container);
                if (container.HasControls()) {
                    foreach (Control control in container.Controls) {
                        EditorPart part = control as EditorPart;

                        if (part != null) {
                            editorParts.Add(part);
                        }
                        else {
                            LiteralControl literal = control as LiteralControl;
                            // Throw an exception if it is *not* a literal containing only whitespace
                            // Don't throw an exception in the designer, since we want only the offending
                            // control to render as an error block, not the whole EditorZone.
                            if (((literal == null) || (literal.Text.Trim().Length != 0)) && !DesignMode) {
                                throw new InvalidOperationException(SR.GetString(SR.EditorZone_OnlyEditorParts, ID));
                            }
                        }
                    }
                }
            }

            return editorParts;
        }
コード例 #2
0
        protected override CatalogPartCollection CreateCatalogParts()
        {
            CatalogPartCollection parts = new CatalogPartCollection();

            if (this._zoneTemplate != null)
            {
                Control container = new NonParentingControl();
                this._zoneTemplate.InstantiateIn(container);
                if (!container.HasControls())
                {
                    return(parts);
                }
                foreach (Control control2 in container.Controls)
                {
                    CatalogPart part = control2 as CatalogPart;
                    if (part != null)
                    {
                        parts.Add(part);
                    }
                    else
                    {
                        LiteralControl control3 = control2 as LiteralControl;
                        if (((control3 == null) || (control3.Text.Trim().Length != 0)) && !base.DesignMode)
                        {
                            throw new InvalidOperationException(System.Web.SR.GetString("CatalogZone_OnlyCatalogParts", new object[] { this.ID }));
                        }
                    }
                }
            }
            return(parts);
        }
コード例 #3
0
 protected internal override WebPartCollection GetInitialWebParts()
 {
     WebPartCollection webParts = new WebPartCollection();
     if (this.ZoneTemplate != null)
     {
         Control container = new NonParentingControl();
         this.ZoneTemplate.InstantiateIn(container);
         if (!container.HasControls())
         {
             return webParts;
         }
         foreach (Control control2 in container.Controls)
         {
             if (control2 is ContentPlaceHolder)
             {
                 if (control2.HasControls())
                 {
                     Control[] array = new Control[control2.Controls.Count];
                     control2.Controls.CopyTo(array, 0);
                     foreach (Control control3 in array)
                     {
                         this.AddWebPartToList(webParts, control3);
                     }
                 }
             }
             else
             {
                 this.AddWebPartToList(webParts, control2);
             }
         }
     }
     return webParts;
 }
コード例 #4
0
        private void LoadAvailableWebParts()
        {
            ArrayList descriptions = new ArrayList();

            if (this.WebPartsTemplate != null)
            {
                Control container = new NonParentingControl();
                this.WebPartsTemplate.InstantiateIn(container);
                if (container.HasControls())
                {
                    Control[] array = new Control[container.Controls.Count];
                    container.Controls.CopyTo(array, 0);
                    foreach (Control control2 in array)
                    {
                        this.AddControlToDescriptions(control2, descriptions);
                    }
                }
            }
            string webPartsListUserControlPath = this.WebPartsListUserControlPath;

            if (!string.IsNullOrEmpty(webPartsListUserControlPath) && !base.DesignMode)
            {
                Control control3 = this.Page.LoadControl(webPartsListUserControlPath);
                if ((control3 != null) && control3.HasControls())
                {
                    Control[] controlArray2 = new Control[control3.Controls.Count];
                    control3.Controls.CopyTo(controlArray2, 0);
                    foreach (Control control4 in controlArray2)
                    {
                        this.AddControlToDescriptions(control4, descriptions);
                    }
                }
            }
            this._descriptions = new WebPartDescriptionCollection(descriptions);
        }
 private void LoadAvailableWebParts()
 {
     ArrayList descriptions = new ArrayList();
     if (this.WebPartsTemplate != null)
     {
         Control container = new NonParentingControl();
         this.WebPartsTemplate.InstantiateIn(container);
         if (container.HasControls())
         {
             Control[] array = new Control[container.Controls.Count];
             container.Controls.CopyTo(array, 0);
             foreach (Control control2 in array)
             {
                 this.AddControlToDescriptions(control2, descriptions);
             }
         }
     }
     string webPartsListUserControlPath = this.WebPartsListUserControlPath;
     if (!string.IsNullOrEmpty(webPartsListUserControlPath) && !base.DesignMode)
     {
         Control control3 = this.Page.LoadControl(webPartsListUserControlPath);
         if ((control3 != null) && control3.HasControls())
         {
             Control[] controlArray2 = new Control[control3.Controls.Count];
             control3.Controls.CopyTo(controlArray2, 0);
             foreach (Control control4 in controlArray2)
             {
                 this.AddControlToDescriptions(control4, descriptions);
             }
         }
     }
     this._descriptions = new WebPartDescriptionCollection(descriptions);
 }
コード例 #6
0
 protected override CatalogPartCollection CreateCatalogParts()
 {
     CatalogPartCollection parts = new CatalogPartCollection();
     if (this._zoneTemplate != null)
     {
         Control container = new NonParentingControl();
         this._zoneTemplate.InstantiateIn(container);
         if (!container.HasControls())
         {
             return parts;
         }
         foreach (Control control2 in container.Controls)
         {
             CatalogPart part = control2 as CatalogPart;
             if (part != null)
             {
                 parts.Add(part);
             }
             else
             {
                 LiteralControl control3 = control2 as LiteralControl;
                 if (((control3 == null) || (control3.Text.Trim().Length != 0)) && !base.DesignMode)
                 {
                     throw new InvalidOperationException(System.Web.SR.GetString("CatalogZone_OnlyCatalogParts", new object[] { this.ID }));
                 }
             }
         }
     }
     return parts;
 }
コード例 #7
0
        protected internal override WebPartCollection GetInitialWebParts() {
            WebPartCollection webParts = new WebPartCollection();

            if (ZoneTemplate != null) {
                // PERF: Instantiate the template into a special control, that does nothing when a child control
                // is added.  This is more performant because the child control is never parented to the temporary
                // control, it's ID is never generated, etc.
                Control container = new NonParentingControl();
                ZoneTemplate.InstantiateIn(container);

                if (container.HasControls()) {
                    ControlCollection controls = container.Controls;
                    foreach (Control control in controls) {
                        if (control is ContentPlaceHolder) {
                            if (control.HasControls()) {
                                Control[] children = new Control[control.Controls.Count];
                                control.Controls.CopyTo(children, 0);
                                foreach (Control child in children) {
                                    AddWebPartToList(webParts, child);
                                }
                            }
                        }
                        else {
                            AddWebPartToList(webParts, control);
                        }
                    }
                }
            }

            return webParts;
        }
コード例 #8
0
        protected internal override WebPartCollection GetInitialWebParts()
        {
            WebPartCollection webParts = new WebPartCollection();

            if (this.ZoneTemplate != null)
            {
                Control container = new NonParentingControl();
                this.ZoneTemplate.InstantiateIn(container);
                if (!container.HasControls())
                {
                    return(webParts);
                }
                foreach (Control control2 in container.Controls)
                {
                    if (control2 is ContentPlaceHolder)
                    {
                        if (control2.HasControls())
                        {
                            Control[] array = new Control[control2.Controls.Count];
                            control2.Controls.CopyTo(array, 0);
                            foreach (Control control3 in array)
                            {
                                this.AddWebPartToList(webParts, control3);
                            }
                        }
                    }
                    else
                    {
                        this.AddWebPartToList(webParts, control2);
                    }
                }
            }
            return(webParts);
        }
コード例 #9
0
        private void LoadAvailableWebParts()
        {
            ArrayList descriptions = new ArrayList();

            if (WebPartsTemplate != null)
            {
                Control container = new NonParentingControl();
                WebPartsTemplate.InstantiateIn(container);
                if (container.HasControls())
                {
                    // Copy container.Controls to a temporary array, since adding the control to the
                    // descriptions may cause it to be reparented to a GenericWebPart, which would
                    // modify the container.Controls collection.
                    Control[] controls = new Control[container.Controls.Count];
                    container.Controls.CopyTo(controls, 0);
                    foreach (Control control in controls)
                    {
                        AddControlToDescriptions(control, descriptions);
                    }
                }
            }

            string webPartsListUserControlPath = WebPartsListUserControlPath;

            if (!String.IsNullOrEmpty(webPartsListUserControlPath) && !DesignMode)
            {
                // Page.LoadControl() throws a null ref exception at design-time
                Control userControl = Page.LoadControl(webPartsListUserControlPath);
                if (userControl != null && userControl.HasControls())
                {
                    // Copy userControl.Controls to a temporary array, since adding the control to the
                    // descriptions may cause it to be reparented to a GenericWebPart, which would
                    // modify the userControl.Controls collection.
                    Control[] controls = new Control[userControl.Controls.Count];
                    userControl.Controls.CopyTo(controls, 0);
                    foreach (Control control in controls)
                    {
                        AddControlToDescriptions(control, descriptions);
                    }
                }
            }

            _descriptions = new WebPartDescriptionCollection(descriptions);
        }
コード例 #10
0
        protected internal override WebPartCollection GetInitialWebParts()
        {
            WebPartCollection webParts = new WebPartCollection();

            if (ZoneTemplate != null)
            {
                // PERF: Instantiate the template into a special control, that does nothing when a child control
                // is added.  This is more performant because the child control is never parented to the temporary
                // control, it's ID is never generated, etc.
                Control container = new NonParentingControl();
                ZoneTemplate.InstantiateIn(container);

                if (container.HasControls())
                {
                    ControlCollection controls = container.Controls;
                    foreach (Control control in controls)
                    {
                        if (control is ContentPlaceHolder)
                        {
                            if (control.HasControls())
                            {
                                Control[] children = new Control[control.Controls.Count];
                                control.Controls.CopyTo(children, 0);
                                foreach (Control child in children)
                                {
                                    AddWebPartToList(webParts, child);
                                }
                            }
                        }
                        else
                        {
                            AddWebPartToList(webParts, control);
                        }
                    }
                }
            }

            return(webParts);
        }
コード例 #11
0
        protected override EditorPartCollection CreateEditorParts()
        {
            EditorPartCollection editorParts = new EditorPartCollection();

            if (_zoneTemplate != null)
            {
                // PERF: Instantiate the template into a special control, that does nothing when a child control
                // is added.  This is more performant because the child control is never parented to the temporary
                // control, it's ID is never generated, etc.
                Control container = new NonParentingControl();

                _zoneTemplate.InstantiateIn(container);
                if (container.HasControls())
                {
                    foreach (Control control in container.Controls)
                    {
                        EditorPart part = control as EditorPart;

                        if (part != null)
                        {
                            editorParts.Add(part);
                        }
                        else
                        {
                            LiteralControl literal = control as LiteralControl;
                            // Throw an exception if it is *not* a literal containing only whitespace
                            // Don't throw an exception in the designer, since we want only the offending
                            // control to render as an error block, not the whole EditorZone.
                            if (((literal == null) || (literal.Text.Trim().Length != 0)) && !DesignMode)
                            {
                                throw new InvalidOperationException(SR.GetString(SR.EditorZone_OnlyEditorParts, ID));
                            }
                        }
                    }
                }
            }

            return(editorParts);
        }
コード例 #12
0
        private void LoadAvailableWebParts() {
            ArrayList descriptions = new ArrayList();

            if (WebPartsTemplate != null) {
                Control container = new NonParentingControl();
                WebPartsTemplate.InstantiateIn(container);
                if (container.HasControls()) {
                    // Copy container.Controls to a temporary array, since adding the control to the
                    // descriptions may cause it to be reparented to a GenericWebPart, which would
                    // modify the container.Controls collection.
                    Control[] controls = new Control[container.Controls.Count];
                    container.Controls.CopyTo(controls, 0);
                    foreach (Control control in controls) {
                        AddControlToDescriptions(control, descriptions);
                    }
                }
            }

            string webPartsListUserControlPath = WebPartsListUserControlPath;
            if (!String.IsNullOrEmpty(webPartsListUserControlPath) && !DesignMode) {
                // Page.LoadControl() throws a null ref exception at design-time
                Control userControl = Page.LoadControl(webPartsListUserControlPath);
                if (userControl != null && userControl.HasControls()) {
                    // Copy userControl.Controls to a temporary array, since adding the control to the
                    // descriptions may cause it to be reparented to a GenericWebPart, which would
                    // modify the userControl.Controls collection.
                    Control[] controls = new Control[userControl.Controls.Count];
                    userControl.Controls.CopyTo(controls, 0);
                    foreach (Control control in controls) {
                        AddControlToDescriptions(control, descriptions);
                    }
                }
            }

            _descriptions = new WebPartDescriptionCollection(descriptions);
        }