public ZoneInfoGrid(int zoneWidthAndHeight, ILandValueCalculator landValueCalculator) { ZoneWidthAndHeight = zoneWidthAndHeight; ZoneInfos = (from x in Enumerable.Range(0, zoneWidthAndHeight) from y in Enumerable.Range(0, zoneWidthAndHeight) let localX = x let localY = y select new ZoneInfo( zonePoint: new ZonePoint { X = localX, Y = localY }, getRelativeZoneInfo: (query) => { var point = new ZonePoint { X = (localX + query.RelativeX), Y = (localY + query.RelativeY) }; ZoneInfo matchingZoneInfo; if (ZoneInfos.TryGetValue(point, out matchingZoneInfo)) { return(new QueryResult <IZoneInfo, RelativeZoneInfoQuery>(query, matchingZoneInfo)); } return(new QueryResult <IZoneInfo, RelativeZoneInfoQuery>(query)); }, landValueCalculator: landValueCalculator ) ).ToDictionary(x => x.Point, x => x); }
public ZoneInfo( ZonePoint zonePoint, GetRelativeZoneInfoDelegate getRelativeZoneInfo, ILandValueCalculator landValueCalculator ) { Point = zonePoint; _getRelativeZoneInfo = getRelativeZoneInfo ?? throw new ArgumentNullException(nameof(getRelativeZoneInfo)); _landValueCalculator = landValueCalculator ?? throw new ArgumentNullException(nameof(landValueCalculator)); }
public ZoneInfo( ZonePoint zonePoint, GetRelativeZoneInfoDelegate getRelativeZoneInfo, ILandValueCalculator landValueCalculator ) { if (zonePoint == null) { throw new ArgumentNullException(nameof(zonePoint)); } if (getRelativeZoneInfo == null) { throw new ArgumentNullException(nameof(getRelativeZoneInfo)); } if (landValueCalculator == null) { throw new ArgumentNullException(nameof(landValueCalculator)); } Point = zonePoint; _getRelativeZoneInfo = getRelativeZoneInfo; _landValueCalculator = landValueCalculator; }