Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var distance        = 159.5;
            var product         = new { Name = "Xbox", Weight = 2.6 };
            var shippingService = new ShippingService();

            var correiosShipping = new Correios();
            var jadlogShipping   = new Jadlog();
            var tntShipping      = new Tnt();
            var upsShipping      = new Ups();

            shippingService.SetCalculateShipping(correiosShipping);
            double correiosShippingPrice = shippingService.Calculate(product.Weight, distance);

            shippingService.SetCalculateShipping(jadlogShipping);
            double jadlogShippingPrice = shippingService.Calculate(product.Weight, distance);

            shippingService.SetCalculateShipping(tntShipping);
            double tntShippingPrice = shippingService.Calculate(product.Weight, distance);

            shippingService.SetCalculateShipping(upsShipping);
            double upsShippingPrice = shippingService.Calculate(product.Weight, distance);

            System.Console.WriteLine($"Correios: {correiosShippingPrice:C2}");
            System.Console.WriteLine($"Jadlog: {jadlogShippingPrice:C2}");
            System.Console.WriteLine($"TNT: {tntShippingPrice:C2}");
            System.Console.WriteLine($"UPS: {upsShippingPrice:C2}");
        }
Exemplo n.º 2
0
        // ---------------- Service functions start --------------------
        private Tnt CutCategoriesAccordingToTheRights(Tnt tnt)
        {
            var u = _usrQueryProcessor.Get(_userSession.UserId);

            if (u != null)
            {
                // ...
                return(tnt);
            }
            return(null);
        }
Exemplo n.º 3
0
        Tile createTileWithEntity(char c, ref Level level)
        {
            Tile tile = new Tile();

            switch (c)
            {
            case 'R':
                level.playerPosition = tile;
                break;

            case 'B':
                Boulder boulder = new Boulder(ref tile);
                break;

            case 'D':
                level.diamonds++;
                Diamond diamond = new Diamond(ref tile);
                break;

            case 'F':
                FireFly fireFly = new FireFly(ref tile);
                break;

            case 'M':
                Mud mud = new Mud(ref tile);
                break;

            case 'S':
                SteelWall steelWall = new SteelWall(ref tile);
                break;

            case 'W':
                Wall wall = new Wall(ref tile);
                break;

            case ' ':
                break;

            case 'E':
                Exit exit = new Exit(ref tile);
                level.addExit(exit);
                break;

            case 'T':
                Tnt tnt = new Tnt(ref tile);
                break;

            case 'H':
                HardenedMush mush = new HardenedMush(ref tile);
                break;
            }
            return(tile);
        }
Exemplo n.º 4
0
        public void TntCloneTest()
        {
            var original = new Tnt {
                Id = 1, map = new Map(), marked = true, number = 1
            };
            var clone = original.Clone();

            //Assert.AreEqual(original.Id, clone.Id);
            Assert.AreEqual(original.bombs, clone.bombs);
            Assert.AreEqual(original.map, clone.map);
            Assert.AreEqual(original.marked, clone.marked);
            Assert.AreEqual(original.number, clone.number);
        }
Exemplo n.º 5
0
        public Tsk GetTsk(long tntId, long srvId, long catId, long tskId)
        {
            var entity = _queryProcessor.Get(tntId);

            if (entity != null)
            {
                Tnt tnt = CutCategoriesAccordingToTheRights(_autoMapper.Map <Tnt>(entity));
                if (tnt != null)
                {
                    // ...
                }
            }
            return(null);
        }
Exemplo n.º 6
0
        public Flw GetFlw(long tntId, long srvId, long catId, long flwId)
        {
            var entity = _queryProcessor.Get(tntId);

            if (entity != null)
            {
                Tnt tnt = CutCategoriesAccordingToTheRights(_autoMapper.Map <Tnt>(entity));
                if (tnt != null)
                {
                    var qqq = tnt.Srv.Where(p => p.Id == srvId).SelectMany(x => x.Cat).Where(o => o.Id == catId).SelectMany(y => y.Flw).Where(z => z.Id == flwId).FirstOrDefault();
                    return(qqq);

                    /*
                     * var www = tnt.Srv.Select(x => x.Cat.Select(y => y.Flw.Where(z => z.Id == flwId).ToList()).ToList()).ToList().FirstOrDefault();
                     * var zzz = tnt.Srv.Where(x => x.Id == srvId).ToList().Select(y => y.Cat.Where(z => z.Id == catId).ToList().Select(o => o.Flw.Where(p => p.Id == flwId).ToList()).ToList()).ToList().FirstOrDefault();
                     * if(zzz != null)
                     *  return zzz[0][0];
                     * return null;
                     */
                }
            }
            return(null);
        }
Exemplo n.º 7
0
        public static void MemoryTest()
        {
            Tnt original = new Tnt();

            original.map    = new Map();
            original.Id     = 1;
            original.bombs  = 0;
            original.marked = true;
            original.number = 1;

            Cell shallowClone = original.Clone();
            Cell deepClone    = original.DeepClone();

            //GCHandle objHandle = GCHandle.Alloc(original, GCHandleType.WeakTrackResurrection);
            //int address = GCHandle.ToIntPtr(objHandle).ToInt32();

            //GCHandle objHandle2 = GCHandle.Alloc(shallowClone, GCHandleType.WeakTrackResurrection);
            //int address2 = GCHandle.ToIntPtr(objHandle).ToInt32();

            //GCHandle objHandle3 = GCHandle.Alloc(deepClone, GCHandleType.WeakTrackResurrection);
            //int address3 = GCHandle.ToIntPtr(objHandle).ToInt32();

            Assert.Pass();
        }
 public void AddTnt(Tnt tnt)
 {
     _session.SaveOrUpdate(tnt);
 }