コード例 #1
0
        /// <summary>
        /// Dynamically adds a web user control to the catalog.
        /// </summary>
        /// <param name="id">ID of the web part</param>
        /// <param name="title">Title of the webpart</param>
        /// <param name="description">Description of the webpart</param>
        /// <param name="imageUrl">Image url of the webpart</param>
        /// <param name="path">The virtual path to the user control for this webpart.</param>
        /// <remarks>This acts as a replacement for declarative catalog to avoid circular file reference warnings.  Controls should be added the during page init.</remarks>
        public void AddControl(string id, string title, string description, string imageUrl, string virtualPath)
        {
            WebPartDescription part = new WebPartDescription(id, title, description, imageUrl);

            _DynamicParts.Add(part);
            _UserControlMappings[id] = virtualPath;
        }
コード例 #2
0
ファイル: XMLCatalogPart.cs プロジェクト: norio-soft/proteo
        /// <summary>
        /// Returns a new instance of the WebPart specified by the description
        /// </summary>
        public override WebPart GetWebPart(WebPartDescription description)
        {
            string typeName = this.GetTypeNameFromXml(description.ID);
            Type   type     = Type.GetType(typeName);

            return(Activator.CreateInstance(type, null) as WebPart);
        }
コード例 #3
0
 public override WebPart GetWebPart(WebPartDescription description)
 {
     if (_UserControlMappings.ContainsKey(description.ID))
     {
         string  path = _UserControlMappings[description.ID];
         Control part = null;
         try
         {
             part = this.Page.LoadControl(path);
         }
         catch { }
         if (part != null)
         {
             part.ID = description.ID;
             GenericWebPart webPart = this.WebPartManager.CreateWebPart(part);
             webPart.Title       = description.Title;
             webPart.Description = description.Description;
             return(webPart);
         }
     }
     else if (_ServerControlMappings.ContainsKey(description.ID))
     {
         WebPart webPart = Activator.CreateInstance(_ServerControlMappings[description.ID]) as WebPart;
         return(webPart);
     }
     return(null);
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        public void AddControl(string classId)
        {
            Type partType = Type.GetType(classId);

            if (partType != null)
            {
                WebPart part = Activator.CreateInstance(partType) as WebPart;
                if (part != null)
                {
                    WebPartDescription partDescription = new WebPartDescription(part);
                    if (!_ServerControlMappings.ContainsKey(partDescription.ID))
                    {
                        _DynamicParts.Add(partDescription);
                        _ServerControlMappings[partDescription.ID] = partType;
                    }
                }
            }
        }
コード例 #6
0
 public virtual WebPart GetWebPart(WebPartDescription description)
 {
 }
コード例 #7
0
 public override WebPart GetWebPart(WebPartDescription description)
 {
     throw new Exception("The method or operation is not implemented.");
 }
コード例 #8
0
	public virtual WebPart GetWebPart(WebPartDescription description) {}
 public int IndexOf(WebPartDescription value)
 {
 }
 public void CopyTo(WebPartDescription[] array, int index)
 {
 }
 // Methods
 public bool Contains(WebPartDescription value)
 {
 }
コード例 #12
0
        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);
        }
コード例 #13
0
	public abstract virtual WebPart GetWebPart(WebPartDescription description) {}
コード例 #14
0
 public abstract virtual WebPart GetWebPart(WebPartDescription description)
 {
 }
 public int IndexOf(WebPartDescription value)
 {
 }
 // Methods
 public bool Contains(WebPartDescription value)
 {
 }