static void Main(string[] args) { var replyResult = UnvalidatedReply.Create("Respond to How to use sockets in C#" , "I have tried for a lot of times to use sockets in C# and I followed several tutorials"); var cmd = new CreateQuestionCmd("How to use sockets in C#" , "I have tried for a lot of times to use sockets in C# and I followed several tutorials " + "\nCan anyone to help me ? " , new string[] { "C#", "Sockets" }, "https://www.infoworld.com/article/3016922/how-to-work-with-sockets-in-c.html "); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); replyResult.Match( Succ: reply => { SendValidityConfirmation(reply); Console.WriteLine("Reply is valid. Reply posted"); return(Unit.Default); }, Fail: ex => { Console.WriteLine($"Invalid reply. Reason: {ex.Message}"); return(Unit.Default); } ); Console.ReadLine(); if (result.form == true) { Console.WriteLine("Do you want to vote this ?"); Console.WriteLine("Yes or No ? Y or N"); string decision = Console.ReadLine(); if (decision.Equals("Y")) { Console.WriteLine("You can give a positive or negative vote: P or N ?"); string vote = Console.ReadLine(); if (vote.Equals("P")) { result.getVotes(1); } else if (vote.Equals("N")) { result.getVotes(-1); } } } }
public Result <ValidatedReply> VerifyReply(UnvalidatedReply reply) { //verified through ML analysis //send validated reply // return(new ValidatedReply(reply.Reply)); }
private static void SendValidityConfirmation(UnvalidatedReply reply) { var verifiedReply = new ValidateReplyService().VerifyReply(reply); verifiedReply.Match( verifiedReply => { new RestReplyOwnerService().SendRestReplyOwnerAck(verifiedReply).Wait(); return(Unit.Default); }, ex => { return(Unit.Default); } ); }
static void Main(string[] args) { var replyResult = UnvalidatedReply.Create("You can restart your compiler, in C# in some moments can didn't see the updates"); replyResult.Match( Succ: reply => { SendValidityConfirmation(reply); Console.WriteLine("Reply is valid. Reply posted"); return(Unit.Default); }, Fail: ex => { Console.WriteLine($"Invalid reply. Reason: {ex.Message}"); return(Unit.Default); } ); Console.ReadLine(); }
static void Main(string[] args) { var replyResult = UnvalidatedReply.Create("You should restart your compiler! (some updates may not be shown)"); replyResult.Match( Succ: reply => { SendValidityConfirmation(reply); Console.WriteLine("The reply is valid. The reply was posted"); return(Unit.Default); }, Fail: ex => { Console.WriteLine($"Invalid reply. Reason: {ex.Message}"); return(Unit.Default); } ); Console.ReadLine(); }
public Result <ValidatedReply> VerifyReply(UnvalidatedReply reply) { return(new ValidatedReply(reply.Reply)); }