public async Task CreateBinder_CustomTypeConverter()
        {
            // Arrange
            var value = new SecretMessage()
            {
                Message = "A message",
            };
            var component = new EventCountingComponent();
            Action <SecretMessage> setter = (_) => value = _;

            var binder = EventCallback.Factory.CreateBinder(component, setter, value);

            var expectedValue = new SecretMessage()
            {
                Message = "TypeConverter may be old, but it still works!",
            };

            // Act
            await binder.InvokeAsync(new UIChangeEventArgs()
            {
                Value = expectedValue.ToString(),
            });

            Assert.Equal(expectedValue.Message, value.Message);
            Assert.Equal(1, component.Count);
        }
        static void Main(string[] args)
        {
            SecretMessage msg1 = new SecretMessage(SayHello);

            msg1();

            PrintMessage pm = new PrintMessage(PrintSomething);

            pm("Delegates are cool!");
        }
예제 #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Введи пароль");

            //можем передать любое число но количество попыток не больше 3
            foreach (var chance in SecretMessage.GetChance(5))
            {
                Console.WriteLine(chance);
            }

            Environment.Exit(0);
        }
        public void Test_Another_Custom_Field_Processor()
        {
            var schema = Resources.SecretMessage;

            var secretMessage = new SecretMessage {
                Message = "Hello There!"
            };
            var avro = secretMessage.ToAvroRecord(schema, new SecretMessageValueGetter());
            var secretMessageReveal =
                avro.FromAvroRecord <SecretMessage>(customValueSetter: new SecretMessageValueSetter());

            // check if the message is encrypted
            Assert.AreNotEqual(Convert.ToString(avro["Message"]), secretMessage.Message);

            // check if restored message is same
            Assert.AreEqual(secretMessage.Message, secretMessageReveal.Message);
        }
        public ActionResult WebhookHandler()
        {
            try
            {
                //Read json data and deserializate it.
                String     jsonData    = new StreamReader(this.Request.InputStream).ReadToEnd();
                JsonSecret jsonPayload = JsonConvert.DeserializeObject <JsonSecret>(jsonData);

                //Create a new SecretMessage
                SecretMessage tmp = new SecretMessage();
                tmp.Message = jsonPayload.secret;

                //Insert the new SecretMessage in the database
                myEntities.SecretMessages.Add(tmp);
                myEntities.SaveChanges();
            }
            catch
            {
            }
            return(View());
        }
        //GET
        public ActionResult Index()
        {
            string message = "Empty (for now)";

            try
            {
                //Find the last message I stored in the database
                SecretMessage tmp = myEntities.SecretMessages.OrderByDescending(messageLinq => messageLinq.SecretId).First();

                if (tmp != null)
                {
                    message = tmp.Message;
                }
            }
            catch
            {
            }

            ViewData["Message"] = message;
            return(View());
        }
        public ActionResult WebhookHandler()
        {
            try
            {
                //Read json data and deserializate it.
                String jsonData = new StreamReader(this.Request.InputStream).ReadToEnd();
                JsonSecret jsonPayload = JsonConvert.DeserializeObject<JsonSecret>(jsonData);

                //Create a new SecretMessage
                SecretMessage tmp = new SecretMessage();
                tmp.Message = jsonPayload.secret;

                //Insert the new SecretMessage in the database
                myEntities.SecretMessages.Add(tmp);
                myEntities.SaveChanges();
            }
            catch
            {

            }
            return View();
        }
예제 #8
0
        public void GameStart()
        {
            Console.WriteLine("Enter your name:");

            string name = Console.ReadLine();

            Console.Clear();

            //Maps
            var map1 = Maps.FirstMap();

            //Secret Messages
            SecretMessage message = new SecretMessage(name);

            //Player
            Player player = new Player(name)
            {
                SecretMessage = message
            };

            Choices.ClassSelection(player);

            //Initianalize Map
            Maps.AddStarsToMap(player, map1);


            do
            {
                foreach (var room in map1)
                {
                    if (player.SecretMessage.CollectedAllStars())
                    {
                        SecretMessage.Message(player.SecretMessage);
                        player.PlayerHasWon = true;
                        Text.Continue();
                        break;
                    }
                    else if (player.NextRoom == room)
                    {
                        CurrentRoom(player, room);
                        break;
                    }
                    else if (player.Health < 1)
                    {
                        player.PlayerHasLost = true;
                    }
                    //else
                    //    Console.WriteLine($"Something went wrong {room.Name}");
                }
                Console.Clear();
            } while (!player.PlayerHasLost && !player.PlayerHasWon);

            if (player.PlayerHasWon)
            {
                Console.WriteLine("You have won.");
            }
            else if (player.PlayerHasLost)
            {
                Console.WriteLine("You Lost :/");
            }
            else
            {
                Console.WriteLine("Something went wrong");
            }

            Text.Continue();
        }