/** * The following are examples of how this method can be used: * With a lambda expression: * GetBuildingsBy((building) => building.Id == building); * * With an anonymous delegate: * GetBuildingsBy(delegate(Building building) { * return building.Id == building; * }); * <param name="match"> Checks if the buildings are the same, or not. </param> * <returns> This method returns all buildings that match the delegate's conditions. </returns> */ public List<Building> GetBuildingsBy(BuildingMatchDelegate match) { List<Building> rtnList = new List<Building>(); foreach (Building building in this._buildings) { if (match(building)) { rtnList.Add(building); } } return rtnList; }
/** * <param name="match"> Check if the building is the same. </param> * <returns> Returns the Building by given condition. Either the building is null if the building couldn't be found. </returns> */ public Building GetBuildingBy(BuildingMatchDelegate match) { Building rtn = null; foreach (Building building in this._buildings) { if (match(building)) { rtn = building; break; } } return rtn; }