Пример #1
0
        private static CompositeMenuCommand GetAssemblyTypesMenuItem(this Assembly assembly, IMenuCommand parent)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            var result = new CompositeMenuCommand(assembly.FullName, parent);

            result.AddCommands(assembly.GetExportedTypes().OrderBy(x => x.FullName).Select(x => GetTypeMenuItem(x, result)));

            return(result);
        }
Пример #2
0
        private static CompositeMenuCommand GetTypeMenuItem(this Type type, IMenuCommand parent)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            var result = new CompositeMenuCommand(type.FullName, parent);

            result.AddCommands(type.GetMembers().OrderBy(x => x.MemberType).ThenBy(x => x.Name).Select(x => GetMemberMenuItem(x, result)));

            return(result);
        }
Пример #3
0
        public static CompositeMenuCommand GetAssembliesMenuItem(this IEnumerable <Assembly> assemblies, string header, IMenuCommand parent = null)
        {
            if (assemblies == null)
            {
                throw new ArgumentNullException(nameof(assemblies));
            }

            var result = new CompositeMenuCommand(header, parent ?? ExitMenuCommand.Instance);

            var commands = assemblies
                           .OrderBy(asm => asm.GetName().Name)
                           .Select(x => GetAssemblyTypesMenuItem(x, result));

            result.AddCommands(commands);

            return(result);
        }