private static IFloorLobbyButton GetDownButton(int floorID) { ButtonFactory btnFactory = new ButtonFactory(); IFloorLobbyButton btn = btnFactory.CreateButton(ButtonType.FloorButton) as IFloorLobbyButton; btn.ButtonID = 0; btn.FloorID = floorID; btn.IsDownButton = true; btn.ButtonName = string.Format("Down Button at Floor {0}", floorID); return(btn); }
public static AbstractFloorLobby CreateFloorLobby(FloorLobbyType floorLobbyType, int floorID) { if (floorLobbyType == FloorLobbyType.Top) { IFloorLobbyButton btn = GetDownButton(floorID); /* Dependency Injection using Constructor Injection*/ return(new TopFloorLobby(btn)); } else if (floorLobbyType == FloorLobbyType.Bottom) { IFloorLobbyButton btn = GetUpButton(floorID); /* Dependency Injection using Constructor Injection*/ return(new BottomFloorLobby(btn)); } else { IFloorLobbyButton upBtn = GetUpButton(floorID); IFloorLobbyButton downBtn = GetDownButton(floorID); /* Dependency Injection using Constructor Injection*/ return(new FloorLobby(upBtn, downBtn)); } }
/* Dependency Injection using Constructor Injection*/ public BottomFloorLobby(IFloorLobbyButton btn) { FloorLobbyType = FloorLobbyType.Bottom; UpButton = btn; }
/* Dependency Injection using Constructor Injection*/ public TopFloorLobby(IFloorLobbyButton btn) { FloorLobbyType = FloorLobbyType.Top; DownButton = btn; }
/* Dependency Injection using Constructor Injection*/ public FloorLobby(IFloorLobbyButton upBtn, IFloorLobbyButton downBtn) { FloorLobbyType = FloorLobbyType.Normal; UpButton = upBtn; DownButton = downBtn; }
private void FloorLobby_ButtonPressed(IButton btn, ButtonEventArgs btnEventArgs) { IFloorLobbyButton flButton = (IFloorLobbyButton)btn; ProcessRequest(flButton.FloorID); }