コード例 #1
0
ファイル: Program.cs プロジェクト: DanialK/fp-in-csharp
        private static Either <Error, Unit> Loop()
        {
            EmployeeAppHelpers.PrintWelcomeMessage();

            return(ReadAction()
                   .Bind(action =>
                         EmployeeApp.Run(action)
                         )
                   .Match(
                       Right: _ => RetryPrompt(),
                       Left: error =>
            {
                Console.WriteLine("Error: " + error.Message);
                return RetryPrompt();
            }
                       ));

            //return (
            //    from action in ReadAction()
            //    from result in EmployeeApp.Run(action)
            //    select result
            //).Match(
            //    Right: _ => RetryPrompt(),
            //    Left: error =>
            //    {
            //        Console.WriteLine("Error: " + error.Message);
            //        return RetryPrompt();
            //    }
            //);
        }
コード例 #2
0
        private static void Loop()
        {
            EmployeeAppHelpers.PrintWelcomeMessage();

            var action = Enum.Parse <UserAction>(Console.ReadLine());

            EmployeeApp.Run(action);

            RetryPrompt();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: DanialK/fp-in-csharp
        private static Option <Unit> Loop()
        {
            EmployeeAppHelpers.PrintWelcomeMessage();

            return(ReadAction()
                   .Bind((action) => EmployeeApp.Run(action))
                   .Match(
                       Some: _ => RetryPrompt(),
                       None: () =>
            {
                Console.WriteLine("Error occured!");
                return RetryPrompt();
            }
                       ));
        }