public NotesInsertionState(IMachineStateOwner owner, ICashRepository cashRepository, Currency currency) { _owner = owner; _cashRepository = cashRepository; _currency = currency; _insertedNotes = Notes.Create(currency); }
public static TMachineState ChangeState <TMachineState>(this IMachineStateOwner owner, params object[] args) where TMachineState : IMachineState { TMachineState newState = CreateNewState <TMachineState>(owner, args); owner.ChangeState(newState); return(newState); }
private static TMachineState CreateNewState <TMachineState>(IMachineStateOwner owner, params object[] args) where TMachineState : IMachineState { Type newStateType = typeof(TMachineState); object[] ctorArgs = new[] { owner }.Concat(args).ToArray(); Type[] ctorArgTypes = ctorArgs.Select(arg => arg.GetType()).ToArray(); ConstructorInfo ctor = newStateType.GetConstructor(ctorArgTypes); Verifiers.Assert(ctor != null, "No constructor with specified signature has been found: {0}", (object)(ctorArgTypes)); return((TMachineState)ctor.Invoke(ctorArgs)); }
public FreshMachineState(IMachineStateOwner owner, ICashRepository cashRepository, Currency currency) { _owner = owner; _cashRepository = cashRepository; _currency = currency; }