/// <summary>
 /// Initializes a new instance of the <see cref="AccountController" /> class.
 /// </summary>
 /// <param name="userVerificationService">The user verification service.</param>
 /// <param name="registrationService">The registration service.</param>
 /// <param name="profileService">The profile service.</param>
 /// <param name="roleProvider">The role provider.</param>
 /// <param name="sessionStateService">The session state service.</param>
 /// <param name="registerFactory">The register factory.</param>
 public AccountController(IUserVerificationService userVerificationService,
     IRegistrationService registrationService,
     IProfileService profileService,
     IRoleProvider roleProvider,
     ISessionStateService sessionStateService,
     IRegisterFactory registerFactory)
 {
     this.userVerificationService = userVerificationService;
     this.registrationService = registrationService;
     this.profileService = profileService;
     this.roleProvider = roleProvider;
     this.sessionService = sessionStateService;
     this.registerFactory = registerFactory;
 }
Ejemplo n.º 2
0
        public ComputerState(
            IByteRegisterFactory byteRegisterFactory,
            IRam ram,
            IBus1Factory bus1,
            IArithmeticLogicUnitFactory aluFactory,
            ICaezRegisterFactory caezRegisterFactory,
            IRegisterFactory <bool> bitRegisterFactory,
            IBus <IByte> bus,
            IBus <IByte> ioBus)
        {
            Io  = new IoPinStates();
            Bus = bus;
            Bus.AddByte(input =>
            {
                Io.Bus.UpdateData(new BusMessage <IByte> {
                    Name = nameof(Bus), Data = input
                });
                Io.Bus.UpdateSubs();
            });

            Io.Bus.AddByte(input =>
            {
                Bus.UpdateData(new BusMessage <IByte> {
                    Name = nameof(Io), Data = input
                });
            });

            GeneralPurposeRegisters = Enumerable.Range(0, 4).Select(index =>
            {
                var name     = $"GeneralPurposeRegister_{index}";
                var register = byteRegisterFactory.Create(data =>
                {
                    bus.UpdateData(new BusMessage <IByte> {
                        Data = data, Name = name
                    });
                    bus.UpdateSubs();
                }, name);
                bus.AddRegister(register);
                return(register);
            }).ToList();
            Ir = byteRegisterFactory.Create(data => {}, nameof(Ir));
            bus.AddRegister(Ir);
            Iar = byteRegisterFactory.Create(data =>
            {
                bus.UpdateData(new BusMessage <IByte> {
                    Data = data, Name = nameof(Iar)
                });
                bus.UpdateSubs();
            }, nameof(Iar));
            bus.AddRegister(Iar);

            Acc = byteRegisterFactory.Create(b =>
            {
                // for some reason updating subs here blows up, this is being updated in Computer
                bus.UpdateData(new BusMessage <IByte> {
                    Data = b, Name = nameof(Acc)
                });
            }, nameof(Acc));

            Alu = aluFactory.Create(input =>
            {
                Acc.Input = input;
                Acc.Apply();
            }, caez =>
            {
                Flags.Input = caez;
                Flags.Apply();
            });

            CarryInTmp        = bitRegisterFactory.Create(output => { Alu.CarryIn = output; }, nameof(CarryInTmp));
            CarryInTmp.Enable = true;

            Bus1 = bus1.Create(updateAlu =>
            {
                Alu.InputB = updateAlu;
                Alu.Apply();
            });

            Tmp = byteRegisterFactory.Create(wire =>
            {
                Bus1.Input = wire;
                Bus1.Apply();
            }, nameof(Tmp));
            bus.AddRegister(Tmp);

            Flags = caezRegisterFactory.Create(data =>
            {
                CarryInTmp.Input = data.C;
                CarryInTmp.Apply();
            }, nameof(Flags));
            Flags.Enable = true;

            Ram = ram;
            Bus.AddRegister(ram.MemoryAddressRegister);

            bus.AddByte(inputByte =>
            {
                Alu.InputA = inputByte;
                Alu.Apply();
            });
        }