コード例 #1
0
        public override WebPart GetWebPart(WebPartDescription description)
        {
            if (description == null)
            {
                throw new ArgumentNullException("description");
            }

            WebPartDescriptionCollection webPartDescriptions = GetAvailableWebPartDescriptions();

            if (!webPartDescriptions.Contains(description))
            {
                throw new ArgumentException(SR.GetString(SR.CatalogPart_UnknownDescription), "description");
            }

            if (_availableWebPart != null)
            {
                return(_availableWebPart);
            }
            // Import the WebPart from its saved XML description.
            using (XmlReader reader = XmlUtils.CreateXmlReader(new StringReader(_importedPartDescription))) {
                if (reader != null && WebPartManager != null)
                {
                    _availableWebPart = WebPartManager.ImportWebPart(reader, out _importErrorMessage);
                }
            }

            // If import failed, clear the cached description
            if (_availableWebPart == null)
            {
                _importedPartDescription      = null;
                _availableWebPartDescriptions = null;
            }
            return(_availableWebPart);
        }
コード例 #2
0
        public override WebPart GetWebPart(WebPartDescription description)
        {
            if (description == null)
            {
                throw new ArgumentNullException("description");
            }

            WebPartDescriptionCollection webPartDescriptions = GetAvailableWebPartDescriptions();

            if (!webPartDescriptions.Contains(description))
            {
                throw new ArgumentException(SR.GetString(SR.CatalogPart_UnknownDescription), "description");
            }

            return(description.WebPart);
        }