private void AddSelectedWebParts() { WebPartZoneBase zone = null; if (base.WebPartManager != null) { zone = base.WebPartManager.Zones[this._selectedZoneID]; } CatalogPart selectedCatalogPart = this.SelectedCatalogPart; WebPartDescriptionCollection availableWebPartDescriptions = null; if (selectedCatalogPart != null) { availableWebPartDescriptions = selectedCatalogPart.GetAvailableWebPartDescriptions(); } if (((zone != null) && zone.AllowLayoutChange) && ((this._selectedCheckBoxValues != null) && (availableWebPartDescriptions != null))) { ArrayList webParts = new ArrayList(); for (int i = 0; i < this._selectedCheckBoxValues.Length; i++) { string str = this._selectedCheckBoxValues[i]; WebPartDescription description = availableWebPartDescriptions[str]; if (description != null) { WebPart webPart = selectedCatalogPart.GetWebPart(description); if (webPart != null) { webParts.Add(webPart); } } } this.AddWebParts(webParts, zone); } }
public override WebPart GetWebPart(WebPartDescription description) { if (description == null) { throw new ArgumentNullException("description"); } if (!this.GetAvailableWebPartDescriptions().Contains(description)) { throw new ArgumentException(System.Web.SR.GetString("CatalogPart_UnknownDescription"), "description"); } if (this._availableWebPart == null) { using (XmlTextReader reader = new XmlTextReader(new StringReader(this._importedPartDescription))) { if ((reader != null) && (base.WebPartManager != null)) { this._availableWebPart = base.WebPartManager.ImportWebPart(reader, out this._importErrorMessage); } } if (this._availableWebPart == null) { this._importedPartDescription = null; this._availableWebPartDescriptions = null; } } return(this._availableWebPart); }
public WebPartDescriptionCollection(ICollection webPartDescriptions) { if (webPartDescriptions == null) { throw new ArgumentNullException("webPartDescriptions"); } _ids = new HybridDictionary(webPartDescriptions.Count, true /* caseInsensitive */); foreach (object obj in webPartDescriptions) { if (obj == null) { throw new ArgumentException(SR.GetString(SR.Collection_CantAddNull), "webPartDescriptions"); } WebPartDescription description = obj as WebPartDescription; if (description == null) { throw new ArgumentException(SR.GetString(SR.Collection_InvalidType, "WebPartDescription"), "webPartDescriptions"); } string id = description.ID; if (!_ids.Contains(id)) { InnerList.Add(description); _ids.Add(id, description); } else { throw new ArgumentException(SR.GetString(SR.WebPart_Collection_DuplicateID, "WebPartDescription", id), "webPartDescriptions"); } } }
public WebPartDescriptionCollection(ICollection webPartDescriptions) { if (webPartDescriptions == null) { throw new ArgumentNullException("webPartDescriptions"); } this._ids = new HybridDictionary(webPartDescriptions.Count, true); foreach (object obj2 in webPartDescriptions) { if (obj2 == null) { throw new ArgumentException(System.Web.SR.GetString("Collection_CantAddNull"), "webPartDescriptions"); } WebPartDescription description = obj2 as WebPartDescription; if (description == null) { throw new ArgumentException(System.Web.SR.GetString("Collection_InvalidType", new object[] { "WebPartDescription" }), "webPartDescriptions"); } string iD = description.ID; if (this._ids.Contains(iD)) { throw new ArgumentException(System.Web.SR.GetString("WebPart_Collection_DuplicateID", new object[] { "WebPartDescription", iD }), "webPartDescriptions"); } base.InnerList.Add(description); this._ids.Add(iD, description); } }
private void RenderItem(HtmlTextWriter writer, WebPartDescription webPartDescription) { string description = webPartDescription.Description; if (String.IsNullOrEmpty(description)) { description = webPartDescription.Title; } RenderItemCheckBox(writer, webPartDescription.ID); writer.Write(" "); if (Zone.ShowCatalogIcons) { string icon = webPartDescription.CatalogIconImageUrl; if (!String.IsNullOrEmpty(icon)) { RenderItemIcon(writer, icon, description); writer.Write(" "); } } RenderItemText(writer, webPartDescription.ID, webPartDescription.Title, description); writer.WriteBreak(); }
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); }
public override WebPart GetWebPart(WebPartDescription description) { if (description == null) { throw new ArgumentNullException("description"); } if (!this.GetAvailableWebPartDescriptions().Contains(description)) { throw new ArgumentException(System.Web.SR.GetString("CatalogPart_UnknownDescription"), "description"); } return description.WebPart; }
public override WebPart GetWebPart(WebPartDescription description) { if (description == null) { throw new ArgumentNullException("description"); } if (!this.GetAvailableWebPartDescriptions().Contains(description)) { throw new ArgumentException(System.Web.SR.GetString("CatalogPart_UnknownDescription"), "description"); } return(description.WebPart); }
/// <summary> /// Returns a new instance of the WebPart specified by the description /// </summary> public override WebPart GetWebPart(WebPartDescription description) { Guid id = new Guid(description.ID); RegisteredWebPart rwp = RegisteredWebPart.FindByID(id); Control control = this.Page.LoadControl(rwp.Url); control.ID = description.ID; return this.WebPartManager.CreateWebPart(control); //string typeName = this.GetTypeNameFromXml(description.ID); //Type type = Type.GetType(typeName); //return Activator.CreateInstance(type, null) as WebPart; }
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); }
public override WebPartDescriptionCollection GetAvailableWebPartDescriptions() { if (DesignMode) { return(DesignModeAvailableWebParts); } if (_availableWebPartDescriptions == null) { WebPartCollection availableWebParts; if (WebPartManager != null) { WebPartCollection closedWebParts = GetClosedWebParts(); if (closedWebParts != null) { availableWebParts = closedWebParts; } else { availableWebParts = new WebPartCollection(); } } else { availableWebParts = new WebPartCollection(); } ArrayList descriptions = new ArrayList(); foreach (WebPart part in availableWebParts) { // Do not show UnauthorizedWebParts (VSWhidbey 429514) if (part is UnauthorizedWebPart) { continue; } WebPartDescription description = new WebPartDescription(part); descriptions.Add(description); } _availableWebPartDescriptions = new WebPartDescriptionCollection(descriptions); } return(_availableWebPartDescriptions); }
private void AddSelectedWebParts() { WebPartZoneBase selectedZone = null; if (WebPartManager != null) { selectedZone = WebPartManager.Zones[_selectedZoneID]; } CatalogPart selectedCatalogPart = SelectedCatalogPart; WebPartDescriptionCollection availableWebParts = null; if (selectedCatalogPart != null) { availableWebParts = selectedCatalogPart.GetAvailableWebPartDescriptions(); } if (selectedZone != null && selectedZone.AllowLayoutChange && _selectedCheckBoxValues != null && availableWebParts != null) { ArrayList selectedWebParts = new ArrayList(); // Fetch all of the WebParts before calling AddWebPart() on any of them. // This is necessary if the CatalogPart would refresh its list of // AvailableWebPartDescriptions in response to adding a WebPart. // PageCatalogPart is an example of this. (VSWhidbey 337539) for (int i = 0; i < _selectedCheckBoxValues.Length; i++) { string value = _selectedCheckBoxValues[i]; WebPartDescription webPartDescription = availableWebParts[value]; if (webPartDescription != null) { WebPart part = selectedCatalogPart.GetWebPart(webPartDescription); if (part != null) { selectedWebParts.Add(part); } } } AddWebParts(selectedWebParts, selectedZone); } }
private void AddControlToDescriptions(Control control, ArrayList descriptions) { WebPart webPart = control as WebPart; if ((webPart == null) && !(control is LiteralControl)) { if (base.WebPartManager != null) { webPart = base.WebPartManager.CreateWebPart(control); } else { webPart = WebPartManager.CreateWebPartStatic(control); } } if ((webPart != null) && ((base.WebPartManager == null) || base.WebPartManager.IsAuthorized(webPart))) { WebPartDescription description = new WebPartDescription(webPart); descriptions.Add(description); } }
private void RenderItem(HtmlTextWriter writer, WebPartDescription webPartDescription) { string description = webPartDescription.Description; if (string.IsNullOrEmpty(description)) { description = webPartDescription.Title; } this.RenderItemCheckBox(writer, webPartDescription.ID); writer.Write(" "); if (this.Zone.ShowCatalogIcons) { string catalogIconImageUrl = webPartDescription.CatalogIconImageUrl; if (!string.IsNullOrEmpty(catalogIconImageUrl)) { this.RenderItemIcon(writer, catalogIconImageUrl, description); writer.Write(" "); } } this.RenderItemText(writer, webPartDescription.ID, webPartDescription.Title, description); writer.WriteBreak(); }
public override WebPartDescriptionCollection GetAvailableWebPartDescriptions() { if (base.DesignMode) { return(DesignModeAvailableWebParts); } if (this._availableWebPartDescriptions == null) { WebPartCollection parts; if (base.WebPartManager != null) { WebPartCollection closedWebParts = this.GetClosedWebParts(); if (closedWebParts != null) { parts = closedWebParts; } else { parts = new WebPartCollection(); } } else { parts = new WebPartCollection(); } ArrayList webPartDescriptions = new ArrayList(); foreach (WebPart part in parts) { if (!(part is UnauthorizedWebPart)) { WebPartDescription description = new WebPartDescription(part); webPartDescriptions.Add(description); } } this._availableWebPartDescriptions = new WebPartDescriptionCollection(webPartDescriptions); } return(this._availableWebPartDescriptions); }
private void AddControlToDescriptions(Control control, ArrayList descriptions) { WebPart webPart = control as WebPart; if ((webPart == null) && !(control is LiteralControl)) { // Fix for DesignMode if (WebPartManager != null) { webPart = WebPartManager.CreateWebPart(control); } else { webPart = WebPartManager.CreateWebPartStatic(control); } } // Fix for DesignMode if (webPart != null && (WebPartManager == null || WebPartManager.IsAuthorized(webPart))) { WebPartDescription description = new WebPartDescription(webPart); descriptions.Add(description); } }
public override WebPartDescriptionCollection GetAvailableWebPartDescriptions() { if (DesignMode) { return DesignModeAvailableWebParts; } if (_availableWebPartDescriptions == null) { WebPartCollection availableWebParts; if (WebPartManager != null) { WebPartCollection closedWebParts = GetClosedWebParts(); if (closedWebParts != null) { availableWebParts = closedWebParts; } else { availableWebParts = new WebPartCollection(); } } else { availableWebParts = new WebPartCollection(); } ArrayList descriptions = new ArrayList(); foreach(WebPart part in availableWebParts) { // Do not show UnauthorizedWebParts (VSWhidbey 429514) if (part is UnauthorizedWebPart) { continue; } WebPartDescription description = new WebPartDescription(part); descriptions.Add(description); } _availableWebPartDescriptions = new WebPartDescriptionCollection(descriptions); } return _availableWebPartDescriptions; }
public bool Contains(WebPartDescription value) { return base.InnerList.Contains(value); }
public bool Contains(WebPartDescription value) { return(default(bool)); }
public abstract WebPart GetWebPart(WebPartDescription description);
public bool Contains(WebPartDescription value) { return(InnerList.Contains(value)); }
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; }
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; }
public override WebPartDescriptionCollection GetAvailableWebPartDescriptions() { Collection<WebPartDescription> colDescriptions = new Collection<WebPartDescription>(); SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); if (siteSettings != null) { using (IDataReader reader = WebPartContent.GetMostPopular (siteSettings.SiteId, WebConfigSettings.NumberOfWebPartsToShowInMiniCatalog)) { while (reader.Read()) { bool allowMultipleInstances = Convert.ToBoolean(reader["AllowMultipleInstancesOnMyPage"]); bool isAssembly = Convert.ToBoolean(reader["IsAssembly"]); String moduleIcon = reader["ModuleIcon"].ToString(); String featureIcon = reader["FeatureIcon"].ToString(); String imageUrl = featureIcon; if (moduleIcon.Length > 0) { imageUrl = moduleIcon; } if (imageUrl.Length > 0) { imageUrl = Page.ResolveUrl("~/Data/SiteImages/FeatureIcons/" + imageUrl); } WebPartDescription wpDescription; if (isAssembly) { wpDescription = new WebPartDescription( reader["WebPartID"].ToString(), reader["ModuleTitle"].ToString(), ResourceHelper.GetResourceString(reader["ResourceFile"].ToString(), reader["FeatureName"].ToString()), imageUrl); } else { wpDescription = new WebPartDescription( reader["ModuleID"].ToString(), reader["ModuleTitle"].ToString(), ResourceHelper.GetResourceString(reader["ResourceFile"].ToString(), reader["FeatureName"].ToString()), imageUrl); } if (allowMultipleInstances) { colDescriptions.Add(wpDescription); } else { if (!PageHasPart(wpDescription.Title, wpDescription.Description)) { colDescriptions.Add(wpDescription); } } } } } WebPartDescriptionCollection wpdCollection = new WebPartDescriptionCollection(colDescriptions); return wpdCollection; }
public int IndexOf(WebPartDescription value) { return default(int); }
public void CopyTo(WebPartDescription[] array, int index) { }
public override WebPart GetWebPart(WebPartDescription description) { return default(WebPart); }
public int IndexOf (WebPartDescription value) { Contract.Ensures (Contract.Result<int>() >= -1); return default(int); }
public int IndexOf(WebPartDescription value) { Contract.Ensures(Contract.Result <int>() >= -1); return(default(int)); }
public void CopyTo(WebPartDescription[] array, int index) { base.InnerList.CopyTo(array, index); }
public bool Contains(WebPartDescription value) { return default(bool); }
public int IndexOf(WebPartDescription value) { return base.InnerList.IndexOf(value); }
public override WebPart GetWebPart(WebPartDescription description) { throw new Exception("The method or operation is not implemented."); }
public override WebPart GetWebPart(WebPartDescription description) { return (WebPart)webparts[description]; }
public override WebPart GetWebPart(WebPartDescription description) { SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); if (siteSettings == null) return null; WebPart webPart = null; if (description.ID.Length == 36) { Guid webPartID = new Guid(description.ID); WebPartContent webPartContent = new WebPartContent(webPartID); if (webPartContent.WebPartId != Guid.Empty) { if (HttpContext.Current != null) { String path = HttpContext.Current.Server.MapPath("~/bin") + Path.DirectorySeparatorChar + webPartContent.AssemblyName + ".dll"; Assembly assembly = Assembly.LoadFrom(path); Type type = assembly.GetType(webPartContent.ClassName, true, true); object obj = Activator.CreateInstance(type); if (obj != null) { webPart = (WebPart)obj; WebPartContent.UpdateCountOfUseOnMyPage(webPartContent.WebPartId, 1); } } } } else { mojoPortal.Business.Module module = new mojoPortal.Business.Module(int.Parse(description.ID)); SiteModuleControl siteModule = Page.LoadControl("~/" + module.ControlSource) as SiteModuleControl; if (siteModule != null) { siteModule.SiteId = siteSettings.SiteId; siteModule.ID = "module" + module.ModuleId.ToString(CultureInfo.InvariantCulture); siteModule.ModuleConfiguration = module; siteModule.RenderInWebPartMode = true; webPart = WebPartManager.CreateWebPart(siteModule); siteModule.ModuleId = module.ModuleId; mojoPortal.Business.Module.UpdateCountOfUseOnMyPage(module.ModuleId, 1); } } return webPart; }
private WebPartDescriptionCollection LoadPluggableWebParts() { webparts.Clear(); Collection<WebPartDescription> collection = new Collection<WebPartDescription>(); //Do this check to keep the Designer from throwing an exception when rendering the catalog. if (WebPartManager != null) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); // Working with a different AppDomain. AppDomain domain = AppDomain.CreateDomain("PluginLoader"); ModulesWebPartFinder finder = (ModulesWebPartFinder)domain.CreateInstanceFromAndUnwrap( executingAssembly.CodeBase, typeof(ModulesWebPartFinder).ToString()); List<Type> pluginsfound = finder.SearchPath(AppDomain.CurrentDomain.RelativeSearchPath); AppDomain.Unload(domain); // Working without a different AppDomain. foreach (Type type in pluginsfound) { try { WebPart plugin = (WebPart)Activator.CreateInstance(type); if (plugin == null) continue; plugin.ID = type.ToString() + "1"; //have to give an ID to the WebPart. WebPartDescription item = new WebPartDescription(plugin); collection.Add(item); webparts.Add(item, plugin); } catch (Exception) { /* Ignore exception */ } } } // We can also create a generic web part to display something withing the catalog. return new WebPartDescriptionCollection(collection); }
public int IndexOf(WebPartDescription value) { return(InnerList.IndexOf(value)); }
public override WebPart GetWebPart(WebPartDescription description) { return(default(WebPart)); }
public void CopyTo (WebPartDescription[] array, int index) { Contract.Ensures (array.Length >= 0); }
public int IndexOf(WebPartDescription value) { return(default(int)); }