Example #1
0
        public static ICommand Create(string programName, IObjectProvider objectProvider)
        {
            var c = new ObjectCommand(null, programName);

            c.CommandSource = new ObjectCommandSource(c, objectProvider);
            return(c.AddHelp());
        }
Example #2
0
        public static Maybe <ICommand> Create(ICommand parent, MemberInfo member, IObjectProvider containingObject)
        {
            var getter = member.GetGetter(containingObject);

            return(member.GetCustomAttribute <CommandAttribute>().ToMaybe()
                   .Select(command =>
            {
                var name = Util.CSharpIdentifierToLongOption(member.Name);
                var c = new ObjectCommand(parent, name);
                c.CommandSource = new ObjectCommandSource(c, getter);
                return (ICommand)c.AddHelp();
            }));
        }