private static List <int> GetIndicesOfBootInstructionType(List <KeyValuePair <BootInstruction, int> > bootInstructions, BootInstruction bootInstruction) { return(bootInstructions .Select((bi, index) => bi.Key == bootInstruction ? index : -1) .Where(i => i >= 0) .ToList()); }
private static List <KeyValuePair <BootInstruction, int> > AmendBootInstructions(List <KeyValuePair <BootInstruction, int> > bootInstructions, int indexOfInstructionToAmend, BootInstruction newInstruction) { var currentBootInstruction = bootInstructions[indexOfInstructionToAmend]; var newBootInstruction = new KeyValuePair <BootInstruction, int>(newInstruction, currentBootInstruction.Value); var newBootInstructions = bootInstructions.Select(x => x).ToList(); newBootInstructions[indexOfInstructionToAmend] = newBootInstruction; return(newBootInstructions); }