Ejemplo n.º 1
0
        public Register FetchRegister(Guid registerId)
        {
            var register = Registers.FirstOrDefault(a => a.Id.Equals(registerId));

            if (register == null)
            {
                throw new BusinessRuleException("Invalid register id supplied");
            }
            return(register);
        }
        public void Run()
        {
            foreach (var instruction in Instructions)
            {
                var target     = Registers.FirstOrDefault(i => i.Name == instruction.TargetRegister);
                var comparison = Registers.FirstOrDefault(i => i.Name == instruction.ComparisonRegister);
                instruction.Perform(target, comparison);

                if (target.Value > HighestEverRegisterValue)
                {
                    HighestEverRegisterValue = target.Value;
                }
            }
        }