コード例 #1
0
ファイル: Program.cs プロジェクト: cammerman/IocOrigins
        static void Main(string[] args)
        {
            var options = new CliOptions();

            if (CommandLine.Parser.Default.ParseArguments(args, options))
            {
                var data =
                    Enumerable.Range(1, 10)
                    .Select(UserWithId)
                    .Cast <object>()
                    .ToList();

                var container = SetupContainer.Build(
                    new InMemoryDataStore(data));

                // Get to work.
                var router = new RouteCommand(container);
                Execute(options, router);

                container.Dispose();
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: cammerman/IocOrigins
        static void Execute(CliOptions options, IRouteCommand router)
        {
            if (options.UserToCreate != null && !options.Admin)
            {
                router.Route(
                    new CreateUserCommand {
                    Username = options.UserToCreate
                });
            }

            if (options.UserToCreate != null && options.Admin)
            {
                if (options.Admin)
                {
                    router.Route(
                        new CreateAdminUserCommand {
                        Username = options.UserToCreate
                    });
                }
            }

            if (options.UserToPromote != null)
            {
                router.Route(
                    new PromoteUserCommand {
                    Username = options.UserToPromote
                });
            }

            if (options.UserToDelete != null)
            {
                router.Route(
                    new DeleteUserCommand {
                    Username = options.UserToDelete
                });
            }
        }