Ejemplo n.º 1
0
        public static List <PortletInventoryItem> GetPortletsFromDll()
        {
            var portlets = new List <PortletInventoryItem>();

            foreach (Assembly privateAssembly in TypeHandler.GetAssemblies())
            {
                AssemblyName asmName = privateAssembly.GetName();
                foreach (Type privateType in privateAssembly.GetTypes())
                {
                    PortletBase wp = null;
                    if (privateType.BaseType != null)
                    {
                        if (privateType.IsSubclassOf(typeof(PortletBase)) && !privateType.IsAbstract && !privateType.IsNotPublic)
                        {
                            object instance = null;
                            try
                            {
                                instance = Activator.CreateInstance(privateType);
                            }
                            catch (Exception e) //logged
                            {
                                Logger.WriteException(e);
                                continue;
                            }
                            wp = (PortletBase)instance;
                        }
                    }
                    if (wp != null)
                    {
                        portlets.Add(PortletInventoryItem.Create(wp, privateAssembly));
                    }
                }
            }
            return(portlets);
        }
Ejemplo n.º 2
0
        public static PortletInventoryItem Create(PortletBase portlet, Assembly assembly)
        {
            var portletItem = new PortletInventoryItem();

            portletItem.Portlet = portlet;

            // get resource image
            var imageName   = string.Concat(portlet.GetType().ToString(), ".png");
            var imageStream = assembly.GetManifestResourceStream(imageName);

            if (imageStream != null)
            {
                portletItem.ImageStream = imageStream;
            }

            return(portletItem);
        }