Exemplo n.º 1
0
        private static void DemoAbstractionThroughInheritance()
        {
            Human mailman = new Mailman("Thomas", 29, 78.5f, 190.11f);
            Human teacher = new Teacher("Gareth", 35, 100.5f, 186.49f);

            //...
            mailman.Work();
            teacher.Work();
        }
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     Console.WriteLine("Hello World!");
     Mailman.From(new System.Net.Mail.MailAddress(""))
     .To("")
     .WithSubject("")
     .WithBody("")
     .Deliver();
 }
Exemplo n.º 3
0
 public MailboxHandler(
     IMailboxHandlerConfiguration mailboxHandler,
     IAliasRepository aliases,
     ILogger <MailboxHandler> logger = null)
 {
     _client      = new MailClient(mailboxHandler, logger);
     _categorizer = new MessageCategorizer(mailboxHandler);
     _mailman     = new Mailman(_client, aliases, mailboxHandler);
     _logger      = logger;
 }
Exemplo n.º 4
0
        private static void DemoAbstractionThroughInterfaces()
        {
            IWorker human = new Mailman("Thomas", 29, 78.5f, 190.11f);
            IWorker ant   = new Ant();
            IWorker robot = new Robot();

            IWorker[] workers = { human, ant, robot };
            foreach (var worker in workers)
            {
                worker.Work();
            }
        }
Exemplo n.º 5
0
        public ActionResult Order(string returnUrl)
        {
            OrderInfo orderInfo = db.OrderInfoes.FirstOrDefault(item => (item.UserId == (int)WebSecurity.CurrentUserId) && (item.OrderStatus == 0));

            orderInfo.OrderStatus = 1;
            db.Entry(orderInfo).CurrentValues.SetValues(orderInfo);
            db.SaveChanges();

            Mailman.SendMail("*****@*****.**", db.UserEmails.First(item => item.UserId == (int)WebSecurity.CurrentUserId).Email, "Order at FurnitureWebshop", "You have ordered some Furniture");

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 6
0
        static async Task Main(string[] args)
        {
            Environment.SetEnvironmentVariable("PUBSUB_EMULATOR_HOST", "localhost:8681");
            var emulatorHostAndPort = Environment.GetEnvironmentVariable("PUBSUB_EMULATOR_HOST");
            //var pubsubProjectId = Environment.GetEnvironmentVariable("PUBSUB_PROJECT_ID");

            var serialization = new JsonSerializerSettings
            {
                MissingMemberHandling = MissingMemberHandling.Error
            };

            var source = new Source(topicId, projectId, subscriptionId);
            var p      = new Mailman(emulatorHostAndPort, projectId, topicId, s => JsonConvert.SerializeObject(s, serialization));

            //first message published creates exchange if non existent
            var msgId = await p.PublishOneAsync(new Msg(rnd.Next(1, 100)), subscriptionId);

            Console.WriteLine(msgId);

            var sink = new Sink(source, subscriptionId);

            var mb = new SimpleMailbox(projectId, emulatorHostAndPort, sink);

            //fake disposable
            using var x = mb.Subscribe(am =>
            {
                Console.WriteLine("A - " + am.Payload);
                am.Ack(false);
            },
                                       Console.WriteLine,
                                       Console.WriteLine);

            Console.WriteLine("press Y to exit.., any other key to publish a new msg");

            while (true)
            {
                if (Console.ReadKey().Key == ConsoleKey.Y)
                {
                    break;
                }

                var newMsgId = await p.PublishOneAsync(new Msg(rnd.Next(1, 100)), subscriptionId);

                Console.WriteLine(newMsgId);
            }
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            var source   = new Source("A", "A.q");
            var endPoint = new EndPoint();
            var sink     = new Sink(source);

            var serialization = new JsonSerializerSettings
            {
                MissingMemberHandling = MissingMemberHandling.Error
            };

            var p = new Mailman(endPoint, source.Exchange, s => JsonConvert.SerializeObject(s, serialization));

            //first message published creates exchange if non existent
            p.PublishOne(new Msg(-1), "");

            //var mb = new SimpleMailbox(endPoint, sink);

            //var d = mb.Subscribe(am =>
            //{
            //    Console.WriteLine("A - " + Encoding.UTF8.GetString(am.EventArgs.Body));
            //    am.Channel.BasicAck(am.EventArgs.DeliveryTag, false);
            //});

            var sfm = new Mailbox <Msg>(endPoint, sink, s => JsonConvert.DeserializeObject <Msg>(s, serialization));

            Console.WriteLine("waiting for messages..");

            var d = sfm.Subscribe(am =>
            {
                if (am.IsOk <Msg>())
                {
                    var msg = am.AsOk <Msg>().Message;
                    Console.WriteLine("ok - " + msg.Bla);
                    am.Confirm();
                }
                else
                {
                    Console.WriteLine("error - " + am.AsError().Ex.Message);
                    am.Confirm();
                }
            },
                                  ex => Console.WriteLine("COMPLETE ERROR"),
                                  () => Console.WriteLine("COMPLETE"));

            var exit  = ConsoleKey.N;
            var count = 0;

            while (exit != ConsoleKey.Y)
            {
                if (count++ % 2 != 0)
                {
                    p.PublishOne(new Msg(count), "");
                }
                else
                {
                    p.PublishOne("{ \"wrong\": \"message\" }", ""); //publish a broken message to test exception handling
                }
                exit = Console.ReadKey().Key;
            }

            //d.Dispose();
            d.Dispose();
        }
Exemplo n.º 8
0
        public override void Update()
        {
            base.Update();
            shittyTimerDontUse++;
            roundStarted = true;

            //Console.WriteLine(roundTimeLeft);

            if (roundTimeLeft % 60 == 0 && !tunnel)
            {
                tunnel       = true;
                tunnelsTimer = 3;
            }

            if (roundTimeLeft < 15 && !resetMatch)
            {
                resetMatch     = true;
                player.gold    = 100;
                player.weapons = new List <Weapon>()
                {
                    new Revolver(player),
                    null,
                    null,
                    null,
                };
                player.weapon = player.weapons[0];
                MainGame.dm.Mailman.sendWeaponSwitch(0);
                for (int i = 0; i < GameObjects.Count; i++)
                {
                    if (GameObjects[i] is Coin)
                    {
                        GameObjects.RemoveAt(i);
                    }
                }
            }

            if (roundTimeLeft > 15)
            {
                firstPlacePlayer = MainGame.dm.Players.OrderByDescending(x => x.gold).ThenBy(x => (int)x.UID).ToList()[0];
                resetMatch       = false;
            }

            if (Input.isKeyDown(Keyboard.Key.F1))
            {
                player.gold     = 10000;
                player.MaxJumps = 10000000;
                player.Health   = 1000000;
            }

            if (Input.isKeyOverride(Keyboard.Key.F12))
            {
                devMode          = true;
                player.MaxJumps  = 10000;
                player.JumpsLeft = 10000;
            }

            if (tunnelsTimer > 0)
            {
                if (shittyTimerDontUse % (60 * 2) == 0)
                {
                    if (!tunnel)
                    {
                        MainGame.soundInstances.Add(new SoundInstance(Content.GetSound("TrainWhistle.wav"), 1, 0, 8));
                    }
                    //if (Input.isKeyTap(Keyboard.Key.C))
                    //{
                    tunnelsTimer--;
                    CliffFace c = new CliffFace();
                    BackgroundGameObjects.Add(c);
                }
            }
            //if (Input.isKeyTap(Keyboard.Key.C))
            //{
            //    tunnelsTimer = 5;
            //}

            if (Input.isKeyTap(Keyboard.Key.T))
            {
                MainGame.soundInstances.Add(new SoundInstance(Content.GetSound("fart.wav"), 0, 1));
            }

            tunnel = false;

            Mailman.HandleMessages();
            Players.ForEach(p => { p.Update(); });
            Projectiles.ForEach(p => { p.Update(); });
            GameObjects.ForEach(p => { p.Update(); });
            BackgroundGameObjects.ForEach(p => { p.Update(); });
            CheckProjectileCollisions();
            ApplyShake();

            if (MainGame.rand.Next(4) == 0)
            {
                for (int i = 0; i < 5; i++)
                {
                    GameObjects.Add(new TrainDust(new Vector2f(60 + (i * 440) + MainGame.rand.Next(70), 215), (float)MainGame.rand.NextDouble() * 90));
                    GameObjects.Add(new TrainDust(new Vector2f(304 + (i * 440) + MainGame.rand.Next(70), 215), (float)MainGame.rand.NextDouble() * 90));
                }
            }
            TrainDust td = new TrainDust(new Vector2f(2190 + MainGame.rand.Next(10), 75), (float)MainGame.rand.NextDouble() * 90, 2);

            GameObjects.Add(td);
            GameObjects.Add(new TrainDust(new Vector2f(1978 + MainGame.rand.Next(10), 75), (float)MainGame.rand.NextDouble() * 90, 1));

            if (Input.isKeyTap(Keyboard.Key.LShift) && !player.Alive)
            {
                if (player.respawnTimer <= 0)
                {
                    //Players.Remove(player);
                    //player = new ClientPlayer(this);
                    //Players.Add(player);
                    player.deathTimer   = 0;
                    player.respawnTimer = player.respawnLength * 60;
                    player.Pos          = new Vector2f(42 + MainGame.rand.Next(1000), 142);
                    player.Health       = 100;
                    player.Alive        = true;
                }
                //player.Pos = new Vector2f(MainGame.rand.Next(42,1800), 142);
                //Mailman.SendRespawn(player.UID);
            }

            if (Input.isKeyDown(Keyboard.Key.P))
            {
                Console.WriteLine(player.Pos);
            }

            if (Input.isKeyDown(Keyboard.Key.R))
            {
                MainGame.Camera.Center += new Vector2f(MainGame.rand.Next(-4, 5) * shakeFactor / 5, MainGame.rand.Next(-4, 5) * shakeFactor / 5);
            }
            trainSound.Update();
            Gui.Update();
        }
Exemplo n.º 9
0
 public void Close()
 {
     Mailman.Disconnect();
 }