protected new void AddItem(string[] inputParams)
        {
            // add character itemClass itemId
            string hero = inputParams[1];
            string itemClass = inputParams[2];
            string itemID = inputParams[3];
            Character temp = GetCharacterById(hero);

            switch (itemClass.ToLower())
            {
                case "axe":
                    Axe axe = new Axe(itemID);
                    temp.AddToInventory(axe);
                    break;
                case "shield":
                    Shield shield = new Shield(itemID);
                    temp.AddToInventory(shield);
                    break;
                case "injection":
                    Injection inj = new Injection(itemID);
                    temp.AddToInventory(inj);
                    break;
                case "pill":
                    Pill pill = new Pill(itemID);
                    temp.AddToInventory(pill);
                    break;
                default:
                    break;
            }
        }
        private new void AddItem(string[] inputParams)
        {
            var character = this.characterList.FirstOrDefault(c => c.Id == inputParams[1]);
            Item item = null;
            switch (inputParams[2])
            {
                case "axe":
                    item = new Axe(inputParams[3], 0, 0, 75);
                    break;
                case "shield":
                    item = new Shield(inputParams[3], 0, 50, 0);
                    break;
                case "injection":
                    item = new Injection(inputParams[3], 200, 0, 0);
                    break;
                case "pill":
                    item = new Pill(inputParams[3], 0, 0, 100);
                    break;
                default:
                    throw new FormatException("This item is not exist!");
            }
            if (character == null)
            {
                throw new InvalidOperationException("This charectar is not exist!");
            }

            character.AddToInventory(item);
        }
        protected override void AddItem(string[] inputParams)
        {
            string character = inputParams[1];
            string itemClass = inputParams[2];
            string itemId = inputParams[3];

            Item item;
            switch (itemClass)
            {
                case "axe":
                    Item axe = new Axe(itemId);
                    characterList.Find(x => x.Id == character).AddToInventory(axe);
                    break;
                case "injection":
                    Item injection = new Injection(itemId);
                    characterList.Find(x => x.Id == character).AddToInventory(injection);
                    break;
                case "pill":
                    Item pill = new Pill(itemId);
                    characterList.Find(x => x.Id == character).AddToInventory(pill);
                    break;
                case "shield":
                    Item shield = new Shield(itemId);
                    characterList.Find(x => x.Id == character).AddToInventory(shield);
                    break;
                default:
                    throw new ArgumentException("Item missing", "No such an item exist.");
            }
        }
Exemple #4
0
        private void ProfilesButton_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count <= 0 || e.RemovedItems.Count <= 0)
            {
                return;
            }

            var oldProfile = (Profile)e.RemovedItems[0];
            var newProfile = (Profile)e.AddedItems[0];

            foreach (var instance in Injection.LeagueInstances)
            {
                foreach (var assembly in oldProfile.InstalledAssemblies.Where(a => a.InjectChecked))
                {
                    Injection.UnloadAssembly(instance, assembly);
                }

                var assembliesToLoad =
                    newProfile.InstalledAssemblies.Where(a => a.InjectChecked || a.Type == AssemblyType.Library);

                foreach (var assembly in assembliesToLoad)
                {
                    Injection.LoadAssembly(instance, assembly);
                }
            }

            TextBoxBase_OnTextChanged(null, null);
        }
Exemple #5
0
        private async void MenuFlyoutItem_Download(object sender, RoutedEventArgs e)
        {
            if (ViewModel.SelectedItem == null)
            {
                return;
            }
            var item = ViewModel.SelectedItem;
            var file = await CreateFile(await GetLibraryFolder(), item.FileName);

            await DownloadRequest(file, item.IsJpeg
                                  ?(Download) new DownloadJpeg { Path = item.FilePath }
                                  : new DownloadRaw {
                Path = item.FilePath, FileSize = item.FileSize
            });

#if __IOS__
            await Injection.SaveToLibrary(file.Path, "HbLink");

            await file.DeleteAsync();
#endif
#if __ANDROID__
            Injection.ScanFile(Context, file.Path);
#endif
            new MessageDialog("download completed").ShowAsync();
        }
        private new void AddItem(string[] inputParams)
        {
            Item item;

            switch (inputParams[2].ToLower())
            {
            case "axe":
                item = new Axe(inputParams[3]);
                break;

            case "shield":
                item = new Shield(inputParams[3]);
                break;

            case "injection":
                item = new Injection(inputParams[3]);
                break;

            case "pill":
                item = new Pill(inputParams[3]);
                break;

            default:
                throw new ApplicationException("No such kind of item.");
            }

            var character = this.characterList.First(c => c.Id == inputParams[1]);

            character.AddToInventory(item);
        }
        protected override void AddItem(string[] inputParams)
        {
            Item currentItem;
            switch (inputParams[2])
            {
                case "axe":
                    currentItem = new Axe(inputParams[3]);
                    break;
                case "shield":
                    currentItem = new Shield(inputParams[3]);
                    break;
                case "pill":
                    currentItem = new Pill(inputParams[3]);
                    this.timeoutItems.Add((Bonus)currentItem);
                    break;
                case "injection":
                    currentItem = new Injection(inputParams[3]);
                    this.timeoutItems.Add((Bonus)currentItem);
                    break;
                default:
                    throw new InvalidOperationException();
                    break;
            }

            Character currentCharacter = this.characterList.First(x => x.Id == inputParams[1]);
            currentCharacter.AddToInventory(currentItem);
        }
Exemple #8
0
 private void ConfigOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
 {
     if (propertyChangedEventArgs.PropertyName == "Install")
     {
         foreach (var instance in Injection.LeagueInstances)
         {
             if (!Config.Instance.Install)
             {
                 foreach (var assembly in
                          Config.Instance.SelectedProfile.InstalledAssemblies.Where(a => a.InjectChecked))
                 {
                     Injection.UnloadAssembly(instance, assembly);
                 }
             }
             else
             {
                 foreach (var assembly in
                          Config.Instance.SelectedProfile.InstalledAssemblies.Where(a => a.InjectChecked))
                 {
                     Injection.LoadAssembly(instance, assembly);
                 }
             }
         }
     }
 }
        protected new void AddItem(string[] inputParams)
        {
            string    characterId = inputParams[1];
            Character character   = characterList.Find(x => x.Id == characterId);

            string itemClass = inputParams[2];
            string itemId    = inputParams[3];

            Item item;

            switch (itemClass)
            {
            case "axe":
                item = new Axe(itemId);
                break;

            case "shield":
                item = new Shield(itemId);
                break;

            case "pill":
                item = new Pill(itemId);
                break;

            case "injection":
            default:
                item = new Injection(itemId);
                break;
            }

            character.AddToInventory(item);
        }
        // GET: ListeRetard
        public async Task <IActionResult> ListeRetard()
        {
            var injections = _context.Injection
                             .Include(i => i.vaccine)
                             .Include(i => i.user)
                             .ToList();

            List <Injection> lastInjections = new List <Injection>();

            // Filter to get only the last injection for each vaccine
            for (int i = 0; i < injections.Count(); i++)
            {
                Injection actualInjection = injections[i];
                Injection injectionFound  = lastInjections.Find(x => x.user.Id.Equals(actualInjection.user.Id) && x.vaccine.Id.Equals(actualInjection.vaccine.Id));
                // If we found an existing injection
                if (injectionFound != null)
                {
                    // If it's a later one, change it
                    if (actualInjection.recall > injectionFound.recall)
                    {
                        lastInjections.Remove(injectionFound);
                        lastInjections.Add(actualInjection);
                    }
                    //Else do nothing
                }
                else   // Else if we found no existing injection, add it
                {
                    lastInjections.Add(actualInjection);
                }
            }

            DateTime now = DateTime.Now;

            return(View(lastInjections.Where(i => i.recall < now)));
        }
        private void OnLogin(string username)
        {
            Utility.Log(LogStatus.Ok, "Login", string.Format("Succesfully signed in as {0}", username), Logs.MainLog);
            Browser.Visibility    = Visibility.Visible;
            TosBrowser.Visibility = Visibility.Visible;
            try
            {
                Utility.MapClassToXmlFile(typeof(Config), Config.Instance, Directories.ConfigFilePath);
            }
            catch
            {
                MessageBox.Show(Utility.GetMultiLanguageText("ConfigWriteError"));
            }

            if (!PathRandomizer.CopyFiles())
            {
            }

            InjectThread = new Thread(
                () =>
            {
                while (true)
                {
                    if (Config.Instance.Install)
                    {
                        Injection.Pulse();
                    }
                    Thread.Sleep(3000);
                }
            });

            InjectThread.Start();
        }
        /// <summary>
        /// Sets up the boost injection for overriding boost behaviour.
        /// </summary>
        public static void setupBoostInjection()
        {
            // Assembly Code to Write address of Player currently boosting to memory.
            string[] injectionString = new string[]
            {
                "use32",
                "add ebx,0x00000BE0",
                "mov dword [0x" + currentPlayerVelocity.ToString("X") + "],ebx",
                "add ebx,-0x00000BE0"
            };

            // Assemble ASM Code.
            byte[] playerPointerASM = serverClient.SendData_Alternate(Message_Type.Client_Call_Assemble_x86_Mnemonics, Serialize_x86_ASM_Mnemonics(injectionString), true);

            // Create new Mixed Injection & Execute.
            Injection boostCSharpInjection = new Injection((IntPtr)BOOSTPAD_BOOST_MEMORY_WRITE_ADDRESS, (boostPlayerDelegate)boostPlayerAction, 6, serverClient, true);

            // Activate Injection
            boostCSharpInjection.Activate();

            // Declare ASM Injection
            ASM_Hook boostASMInjection = new ASM_Hook((IntPtr)BOOSTPAD_BOOST_MEMORY_WRITE_ADDRESS, playerPointerASM, 6, serverClient, true);

            // Activate Injection
            boostASMInjection.Activate();

            // Append Hooks onto List
            boostPlayerInjection.Add(boostCSharpInjection);
            boostPlayerInjection.Add(boostASMInjection);
        }
Exemple #13
0
        protected void AddItem(string[] inputParams)
        {
            switch (inputParams[2])
            {
            case "axe":
                this.GetCharacterById(inputParams[1])
                .AddToInventory(new Axe(inputParams[3]));
                break;

            case "shield":
                this.GetCharacterById(inputParams[1])
                .AddToInventory(new Shield(inputParams[3]));
                break;

            case "injection":
                Injection currentInjection = new Injection(inputParams[3]);
                this.GetCharacterById(inputParams[1])
                .AddToInventory(currentInjection);
                this.timeoutItems.Add(currentInjection);
                break;

            case "pill":
                Pill currentPill = new Pill(inputParams[3]);
                this.GetCharacterById(inputParams[1])
                .AddToInventory(currentPill);
                this.timeoutItems.Add(currentPill);
                break;

            default:
                Console.WriteLine("Invalid Item!");
                break;
            }
        }
Exemple #14
0
        /// <summary>
        /// Выполнение операции сохранения
        /// </summary>
        public void Run()
        {
            // заглушка
            IBankCredit credit = new Credits();

            switch (Client) // создание в зависимости от типа
            {
            case Clients c:
            {
                credit = ClientsFactory.GetCredit("кр", Sum, Loan, (Client as Clients).Id, VipBonus, Target);

                break;
            }

            case Firms c:
            {
                credit = ClientsFactory.GetCredit("л", Sum, Loan, (Client as Firms).Id, VipBonus, Target);
                break;
            }
            }
            Injection.Save(credit, new RepositoryReal(App.context)); // Выполнение логики для сохранения из объекта класса
            //Injection.Save(credit,App.context); // Выполнение логики для сохранения из объекта класса

            // выполнение логики путем зауска делегата

            creditHandler?.Invoke(credit);
        }
Exemple #15
0
    public void Inject(Injection injection, PlayerBase target, SyringeZone zone)
    {
        switch (injection)
        {
        case Injection.Hyperactive:
            target.LevelUp(1);
            break;

        case Injection.Hadoken:
            target.LevelUp(2);
            break;

        case Injection.Sabotage:
            target.Sabotaged();
            break;

        case Injection.Heal:
            target.GetComponent <Fighter>().TakeDamage(-GameManagerPersistent.Instance.healValue, this.gameObject);
            break;
        }

        tiredness += 1;
        injectZone.gameObject.SetActive(false);
        heldItem  = null;
        canInject = false;

        syringeFeedback.SetActive(false);
        GameManagerPersistent.Instance.UpdateSyringe();
        zone.playersInZone.Clear();
        zone.gameObject.SetActive(false);
    }
Exemple #16
0
 private void GameSettingOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
 {
     foreach (var instance in Injection.LeagueInstances)
     {
         Injection.SendConfig(instance);
     }
 }
        protected new void AddItem(string[] inputParams)
        {
            Character characterToAcceptIthem = GetCharacterById(inputParams[1]);
            string itemId = inputParams[3];
            Item itemToAdd;

            switch (inputParams[2].Trim())
            {
                case "axe":
                    itemToAdd = new Axe(itemId);
                    characterToAcceptIthem.AddToInventory(itemToAdd);
                    break;
                case "pill":
                    itemToAdd = new Pill(itemId);
                    characterToAcceptIthem.AddToInventory(itemToAdd);
                    break;
                case "shield":
                    itemToAdd = new Shield(itemId);
                    characterToAcceptIthem.AddToInventory(itemToAdd);
                    break;
                case "injection":
                    itemToAdd = new Injection(itemId);
                    characterToAcceptIthem.AddToInventory(itemToAdd);
                    break;
            }
        }
        public HtmlToTextConverter(
            IHtmlParser parser,
            TextOutput output,
            Injection injection,
            bool convertFragment,
            bool preformattedText,
            bool testTreatNbspAsBreakable,
            bool traceShowTokenNum,
            int traceStopOnTokenNum)
        {
            this.normalizedInput = (parser is HtmlNormalizingParser);

            this.treatNbspAsBreakable = testTreatNbspAsBreakable;

            this.convertFragment = convertFragment;

            this.parser = parser;
            this.parser.SetRestartConsumer(this);

            if (!convertFragment)
            {
                this.injection = injection;

                if (this.injection != null && this.injection.HaveHead)
                {
                    this.injection.Inject(true, this.output);
                }
            }
            else
            {
                this.insidePre = preformattedText;
            }
        }
Exemple #19
0
 protected void AddItem(string[] inputParams)
 {
     Character characterToAcceptIitem = GetCharacterById(inputParams[1]);
     Item itemToAdd;
     switch (inputParams[2])
     {
         case "axe":
             itemToAdd = new Axe(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         case "shield":
             itemToAdd = new Shield(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         case "injection":
             itemToAdd = new Injection(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         case "pill":
             itemToAdd = new Pill(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         default:
             break;
     }
 }
Exemple #20
0
 protected new void AddItem(string[] inputParams)
 {
     var character = GetCharacterById(inputParams[1]);
     Item item;
     switch (inputParams[2].ToLower())
     {
         case "axe":
             item = new Axe(inputParams[3]);
             character.AddToInventory(item);
             break;
         case "shield":
             item = new Shield(inputParams[3]);
             character.AddToInventory(item);
             break;
         case "pill":
             item = new Pill(inputParams[3]);
             character.AddToInventory(item);
             break;
         case "injection":
             item = new Injection(inputParams[3]);
             character.AddToInventory(item);
             break;
         default:
             break;
     }
 }
Exemple #21
0
        public IMatrix Restore(string path)
        {
            int[,] array = null;

            using (var reader = new StreamReader(path))
            {
                int lineCount = 0;
                while (!reader.EndOfStream)
                {
                    var values = reader.ReadLine().Split(' ');

                    if (lineCount == 0)
                    {
                        array = new int[values.Count(), values.Count()];
                    }

                    for (int i = 0; i < values.Length; i++)
                    {
                        array[lineCount, i] = int.Parse(values[i]);
                    }
                    lineCount++;
                }
            }

            if (array == null)
            {
                throw new IOException("File is empty");
            }

            var matrix = Injection.Resolve <IMatrix>();

            matrix.SetArray(array);

            return(matrix);
        }
Exemple #22
0
        protected override void AddItem(string[] inputParams)
        {
            Item currentItem;

            switch (inputParams[2])
            {
            case "axe":
                currentItem = new Axe(inputParams[3]);
                break;

            case "shield":
                currentItem = new Shield(inputParams[3]);
                break;

            case "pill":
                currentItem = new Pill(inputParams[3]);
                this.timeoutItems.Add((Bonus)currentItem);
                break;

            case "injection":
                currentItem = new Injection(inputParams[3]);
                this.timeoutItems.Add((Bonus)currentItem);
                break;

            default:
                throw new InvalidOperationException();
                break;
            }

            Character currentCharacter = this.characterList.First(x => x.Id == inputParams[1]);

            currentCharacter.AddToInventory(currentItem);
        }
        public async Task <IActionResult> AddInjection([Bind("date,recall,brand,lot")] Injection injection, int Vaccine)
        {
            var user = await _context.User.FindAsync(6);

            var vaccine = await _context.Vaccine.FindAsync(Vaccine);

            injection.user    = user;
            injection.vaccine = vaccine;

            ModelState.Clear();
            TryValidateModel(injection);

            if (ModelState.IsValid)
            {
                _context.Add(injection);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["users"]    = new SelectList(_context.User, "Id", "firstName", "lastName");
            ViewData["vaccines"] = new SelectList(_context.Vaccine, "Id", "name");

            return(View(injection));
        }
Exemple #24
0
        protected new void AddItem(string[] inputParams)
        {
            string characterId = inputParams[1];
            Character character = characterList.Find(x => x.Id == characterId);

            string itemClass = inputParams[2];
            string itemId = inputParams[3];

            Item item;
            switch (itemClass)
            {
                case "axe":
                    item = new Axe(itemId);
                    break;
                case "shield":
                    item = new Shield(itemId);
                    break;
                case "pill":
                    item = new Pill(itemId);
                    break;
                case "injection":
                default:
                    item = new Injection(itemId);
                    break;
            }

            character.AddToInventory(item);
        }
Exemple #25
0
        public async Task NavigateFromMenu(int id)
        {
            if (!MenuPages.ContainsKey(id))
            {
                switch (id)
                {
                case (int)MenuItemType.Browse:
                    MenuPages.Add(id, new NavigationPage(_itemsPageFactory()));
                    break;

                case (int)MenuItemType.About:
                    MenuPages.Add(id, new NavigationPage(new AboutPage()));
                    break;

                case (int)MenuItemType.Ptt:
                    MenuPages.Add(id, new NavigationPage(Injection.Resolve <PttPage>()));
                    break;
                }
            }

            var newPage = MenuPages[id];

            if (newPage != null && Detail != newPage)
            {
                Detail = newPage;

                if (Device.RuntimePlatform == Device.Android)
                {
                    await Task.Delay(100);
                }

                IsPresented = false;
            }
        }
Exemple #26
0
        public TextToTextConverter(
            TextParser parser,
            TextOutput output,
            Injection injection,
            bool convertFragment,
            bool treatNbspAsBreakable,
            Stream traceStream,
            bool traceShowTokenNum,
            int traceStopOnTokenNum)
        {
#if DEBUG
            if (traceStream != null)
            {
                trace = new TestHtmlTrace(traceStream, traceShowTokenNum, traceStopOnTokenNum);
            }
#endif
            this.treatNbspAsBreakable = treatNbspAsBreakable;

            this.convertFragment = convertFragment;

            this.output = output;
            this.parser = parser;

            if (!this.convertFragment)
            {
                this.injection = injection;
            }
        }
Exemple #27
0
 private void GameSettingOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
 {
     if (Injection.IsInjected)
     {
         Injection.SendConfig(IntPtr.Zero);
     }
 }
Exemple #28
0
        public Result SaveInjection(Injection Inj)
        {
            Result Res = new Result();

            Res = bll.SaveInjection(Inj);
            return(Res);
        }
Exemple #29
0
 async void RegisterTypes(Injection injection)
 {
     injection.Register <Resampler>(i => new Resampler());
     injection.RegisterSingleton <IAudioSource>(i => new AAudioSource(i.Get <Resampler>()));
     injection.RegisterSingleton <IAudioPlayer>(i => new AAudioPlayer(i.Get <Resampler>()));
     await Task.CompletedTask;
 }
Exemple #30
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            // Injeção de dependencia do Automapper
            var     config = AutoMapperInjection.Config();
            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            // Injeção de dependencia do projeto em geral.
            Injection.Inject(services);

            // Configurando o serviço de documentação do Swagger
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1",
                             new Microsoft.OpenApi.Models.OpenApiInfo
                {
                    Title       = "Cadastro de Usuários",
                    Version     = "v1",
                    Description = "Exemplo de API REST criada com o ASP.NET Core para teste na Confitec",
                });

                string caminhoAplicacao =
                    AppDomain.CurrentDomain.BaseDirectory;
                string nomeAplicacao =
                    AppDomain.CurrentDomain.FriendlyName;
                string caminhoXmlDoc =
                    Path.Combine(caminhoAplicacao, $"{nomeAplicacao}.xml");

                c.IncludeXmlComments(caminhoXmlDoc);
            });
        }
Exemple #31
0
        protected new void AddItem(string[] inputParams)
        {
            Item item;

            switch (inputParams[2])
            {
            case "axe":
                item = new Axe(inputParams[3]);
                break;

            case "shield":
                item = new Shield(inputParams[3]);
                break;

            case "injection":
                item = new Injection(inputParams[3]);
                break;

            case "pill":
                item = new Pill(inputParams[3]);
                break;

            default:
                throw new ApplicationException("This item doesn't exist!");
            }

            Character character = GetCharacterById(inputParams[1]);

            character.AddToInventory(item);
        }
Exemple #32
0
        private IClient BuildClient(ProcessHandler onprocess, ThreadHandler onthread)
        {
            Client curclient;

            //- inject our assembly into the client process (where an instance of the Client class is created!
            Injection.Inject(onprocess, onthread, Assembly.GetExecutingAssembly(), typeof(InjectedProcess));

            //- create a proxy to the remote client object
            curclient = (Client)Server.GetObject(typeof(Client), (int)onprocess.PID);

            //- wait for server to become available
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            while ((!IsValid(curclient) && (sw.ElapsedMilliseconds < 1000)))
            {
                Thread.Sleep(0);
            }
            sw.Stop();

            if (IsValid(curclient))
            {
                return(curclient.ActualClient);
            }
            else
            {
                return(null);
            }
        }
Exemple #33
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //获取资源管理器的进程ID
            Process[] Desc = Process.GetProcessesByName("explorer");
            if (Desc.Length == 0)
            {
                return;
            }
            int pid = Desc[0].Id;

            //实例化一个线程注入类
            Injection MyInjection = new Injection();

            //提升到Debug权限
            bool IsOk = MyInjection.EnablePrivilege(Privilege.SE_DEBUG_NAME, true);

            //注入一个线程
            IntPtr tHandle = MyInjection.RemoteThread(pid, @"G:\Soft Develop\Thread Injection\Release\Win64Test.dll", tState.Active, MyCall);

            //注入失败(请不要尝试用32位软件注入64位软件)
            if (tHandle == IntPtr.Zero)
            {
                MessageBox.Show("注入失败。", "线程注入测试", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            //挂起注入的线程
            bool Suspend = MyInjection.SuspendThread();

            //恢复注入的线程
            bool Resume = MyInjection.ResumeThread();
        }
        public async Task <IActionResult> Edit(int id, [Bind("idInjection,date,date_rappel")] Injection injection)
        {
            if (id != injection.idInjection)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(injection);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InjectionExists(injection.idInjection))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(injection));
        }
Exemple #35
0
        protected void AddItem(string[] inputParams)
        {
            Item itemToAdd;

            switch (inputParams[2])
            {
            case "axe":
                Axe axe = new Axe(inputParams[3]);
                itemToAdd = axe;
                GetCharacterById(inputParams[1]).AddToInventory(itemToAdd);
                break;

            case "shield":
                Shield shield = new Shield(inputParams[3]);
                itemToAdd = shield;
                GetCharacterById(inputParams[1]).AddToInventory(itemToAdd);
                break;

            case "pill":
                Pill pill = new Pill(inputParams[3]);
                itemToAdd = pill;
                GetCharacterById(inputParams[1]).AddToInventory(itemToAdd);
                break;

            case "injection":
                Injection injection = new Injection(inputParams[3]);
                itemToAdd = injection;
                GetCharacterById(inputParams[1]).AddToInventory(itemToAdd);
                break;

            default:
                break;
            }
        }
        // GET: ListeGrippe
        public async Task <IActionResult> ListeGrippe()
        {
            DateTime past = DateTime.Now.AddYears(-1);

            // Retrieve users that are vaccinated from the 'Grippe'
            var injections = _context.Injection
                             .Include(i => i.vaccine)
                             .Include(i => i.user)
                             .Where(i => i.vaccine.name.Equals("Grippe") && i.date >= past)
                             .ToList();

            var users = _context.User.ToList();

            for (int i = 0; i < injections.Count(); i++)
            {
                Injection actualInjection = injections[i];
                User      userFound       = users.Find(x => x.Id.Equals(actualInjection.user.Id));
                // If we found a vaccinated user, we remove him
                if (userFound != null)
                {
                    users.Remove(userFound);
                }
            }
            return(View(users));
        }
Exemple #37
0
        private void AddItem(string[] inputParams)
        {
            Item item = null;

            switch (inputParams[2])
            {
            case "axe":
                item = new Axe(inputParams[3]);
                break;

            case "shield":
                item = new Shield(inputParams[3]);
                break;

            case "pill":
                item = new Pill(inputParams[3]);
                break;

            case "injection":
                item = new Injection(inputParams[3]);
                break;
            }

            var target = base.GetCharacterById(inputParams[1]);

            target.AddToInventory(item);
        }
Exemple #38
0
        protected new void AddItem(string[] inputParams)
        {
            Character characterToAcceptIitem = GetCharacterById(inputParams[1]);
            Item      itemToAdd;

            switch (inputParams[2])
            {
            case "axe":
                itemToAdd = new Axe(inputParams[3]);
                characterToAcceptIitem.AddToInventory(itemToAdd);
                break;

            case "shield":
                itemToAdd = new Shield(inputParams[3]);
                characterToAcceptIitem.AddToInventory(itemToAdd);
                break;

            case "injection":
                itemToAdd = new Injection(inputParams[3]);
                characterToAcceptIitem.AddToInventory(itemToAdd);
                break;

            case "pill":
                itemToAdd = new Pill(inputParams[3]);
                characterToAcceptIitem.AddToInventory(itemToAdd);
                break;

            default:
                break;
            }
        }
 public DependencyRegistry(Injection registryType)
 {
     switch (registryType)
     {
         case Injection.DataAccess:
             StructureMap.ObjectFactory.Configure(x => x.AddRegistry(new DataAccess.DependencyRegistry()));
             break;
         case Injection.ServiceLayer:
             StructureMap.ObjectFactory.Configure(x => x.AddRegistry(new DependencyRegistry()));
             break;
     }
 }
Exemple #40
0
        public void RegisterType_Transient()
        {
            var injector = new Injection();

            injector.Register<ITimer, MyTimer>(LifestyleType.Transient);

            var actual1 = injector.Resolve(typeof(ITimer));
            var actual2 = injector.Resolve(typeof(ITimer));

            Assert.IsInstanceOf<ITimer>(actual1);
            Assert.IsInstanceOf<ITimer>(actual2);
            Assert.AreNotSame(actual1, actual2);
        }
Exemple #41
0
        public void RegisterComplexType_Singleton()
        {
            var injector = new Injection();

            injector.Register<ITimer, MyTimer>(LifestyleType.Transient);
            //Here we fully register the complex type to utilize the container LSM for singleton
            injector.Register<IComplex, Complex>(LifestyleType.Singleton);

            var actual1 = injector.Resolve(typeof(IComplex));
            var actual2 = injector.Resolve(typeof(IComplex));

            Assert.IsInstanceOf<IComplex>(actual1);
            Assert.IsInstanceOf<IComplex>(actual2);
            Assert.AreSame(actual1, actual2);
        }
Exemple #42
0
        public void RegisterComplexType_TransientWithSingletonDependency()
        {
            var injector = new Injection();

            injector.Register<ITimer, MyTimer>(LifestyleType.Singleton);
            //The Injector container will handel unregistered resolves but the
            //following line could be uncommented to officially register the "Complex" type.
            //injector.Register<IComplex, Complex>(LifestyleType.Transient);

            var actual1 = (Complex)injector.Resolve(typeof(Complex));
            var actual2 = (Complex)injector.Resolve(typeof(Complex));

            Assert.AreNotSame(actual1, actual2);
            Assert.AreSame(actual1.Timer, actual2.Timer);
        }
 private Injection[] DetectInjections(ServiceName name)
 {
     var memberSetters = provider.GetMembers(name.Type);
     var result = new Injection[memberSetters.Length];
     for (var i = 0; i < result.Length; i++)
     {
         var member = memberSetters[i].member;
         try
         {
             result[i].value = container.Resolve(member.MemberType(),
                 name.Contracts.Concat(InternalHelpers.ParseContracts(member)));
             result[i].value.CheckSingleInstance();
         }
         catch (SimpleContainerException e)
         {
             const string messageFormat = "can't resolve member [{0}.{1}]";
             throw new SimpleContainerException(string.Format(messageFormat, member.DeclaringType.FormatName(), member.Name), e);
         }
         result[i].setter = memberSetters[i].setter;
     }
     return result;
 }
        protected void AddItem(string[] inputParams)
        {
            string id = inputParams[3];
            Item item = null;

            switch (inputParams[2])
            {
                case "axe":
                    item = new Axe(id);
                    break;
                case "shield":
                    item = new Shield(id);
                    break;
                case "injection":
                    item = new Injection(id);
                    break;
                case "pill":
                    item = new Pill(id);
                    break;
            }

            this.GetCharacterById(inputParams[1]).AddToInventory(item);
        }
Exemple #45
0
 public void Basic()
 {
     var container = new Injection(null, null);
     var connstr = "my database connection string";
     container.Register("connname", connstr);
     container.Register("MaxConnecionCount", "5");
     container.Register("AcceptMethod", "GET");
     container.Register<DbContext>();
     container.Register<UserProvider>();
     container.Register<UserBusiness>();
     container.Register<UserController>();
     var item = container.Find(typeof(UserController));
     Assert.NotNull(item);
     var controller = item.GetOrCreateInstance() as UserController;
     
     Assert.NotNull(controller);
     Assert.NotNull(controller.Business);
     Assert.NotNull(controller.Business.DbProvider);
     Assert.NotNull(controller.Business.DbProvider.DbContext);
     Assert.Equal(connstr,controller.Business.DbProvider.DbContext.ConnName);
     Assert.Equal(5,controller.Business.DbProvider.DbContext.MaxConnecionCount);
     Assert.Equal(HttpMethods.GET,controller.AcceptMethod);
     Assert.Null(controller.Business.BusinessId);
 }
        private new void AddItem(string[] inputParams)
        {
            Item item;
            switch (inputParams[2].ToLower())
            {
                case "axe":
                    item = new Axe(inputParams[3]);
                    break;
                case "shield":
                    item = new Shield(inputParams[3]);
                    break;
                case "injection":
                    item = new Injection(inputParams[3]);
                    break;
                case "pill":
                    item = new Pill(inputParams[3]);
                    break;
                default:
                    throw new ApplicationException("No such kind of item.");
            }

            var character = this.characterList.First(c => c.Id == inputParams[1]);
            character.AddToInventory(item);
        }
        private Item CreateBonus(string[] inputParams)
        {
            Bonus bonus = null;
            switch (inputParams[2])
            {
                case "pill":
                    bonus = new Pill(inputParams[3]);
                    break;
                case "injection":
                    bonus = new Injection(inputParams[3]);
                    break;
                default:
                    throw new InvalidOperationException("Invalid Item or Bonus");
            }

            this.timeoutItems.Add(bonus);
            return (Item)bonus;
        }
Exemple #48
0
        private new void AddItem(string[] inputParams)
        {
            Item item;
            switch (inputParams[2].ToLower())
            {
                case "axe":
                    item = new Axe(inputParams[3]);
                    break;
                case "shield":
                    item = new Shield(inputParams[3]);
                    break;
                case "injection":
                    item = new Injection(inputParams[3]);
                    break;
                case "pill":
                    item = new Pill(inputParams[3]);
                    break;
                default:
                    throw new ApplicationException("No such kind of item.");
            }

            string targetCharecterId = inputParams[1];

            var character = this.characterList.Where(ch => ch.IsAlive)
                .FirstOrDefault(c => c.Id == targetCharecterId);

            if (character == null)
                throw new ArgumentException("No character with id " + targetCharecterId);

            character.AddToInventory(item);
        }
Exemple #49
0
        protected void AddItem(string[] inputParams)
        {
            Character target = this.characterList.FirstOrDefault(x => x.Id == inputParams[1]);

            if (target == null)
            {
                throw new InvalidOperationException("Character does not exists!");
            }

            string itemClass = inputParams[2].ToLower();
            string itemID = inputParams[3];
            switch (itemClass)
            {
                case "axe":
                    Item currentAxe = new Axe(itemID, target);
                    break;
                case "shield":
                    Item currenShield = new Shield(itemID, target);
                    break;
                case "pill":
                    Bonus currentPill = new Pill(itemID, target);
                    this.timeoutItems.AddLast(currentPill);
                    break;
                case "injection":
                    Bonus currentInjection = new Injection(itemID, target);
                    this.timeoutItems.AddLast(currentInjection);
                    break;
                default:
                    {
                        throw new InvalidOperationException("Invalid input!");
                    }
            }
        }
 public void NativeInjectorCreated(Injection.Native.NativeWrapper injector)
 {
     _Writer.WriteLine("Injector created: {0}", injector.GetType().FullName);
     _Writer.Flush();
 }
 public InstanceFactoryGenerator(Injection injection)
 {
     this.Injection = injection;
 }