Create() public static method

public static Create ( PortletBase portlet, Assembly assembly ) : PortletInventoryItem
portlet PortletBase
assembly System.Reflection.Assembly
return PortletInventoryItem
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);
        }