Esempio n. 1
0
        private static List <ToolButton> GetAllButtons()
        {
            List <Type>       derivedTypes = VType.GetDerivedTypes(typeof(ToolButton), Assembly.GetExecutingAssembly());
            List <ToolButton> buttons      = new List <ToolButton>();

            derivedTypes.ForEach(x => buttons.Add((ToolButton)Activator.CreateInstance(x)));
            return(buttons);
        }
Esempio n. 2
0
        public static List <Type> GetDerivedTypes(Type baseType, Assembly assembly)
        {
            // Get all types from the given assembly
            Type[]      types        = assembly.GetTypes();
            List <Type> derivedTypes = new List <Type>();

            for (int i = 0, count = types.Length; i < count; i++)
            {
                Type type = types[i];
                if (VType.IsSubclassOf(type, baseType))
                {
                    // The current type is derived from the base type,
                    // so add it to the list
                    derivedTypes.Add(type);
                }
            }

            return(derivedTypes);
        }