public static void UpdateShips(this Store dsRoot, kcsapi_ship2[] raw) { var ds = dsRoot.Ships; var shipIds = ds.AllIds.ToList(); foreach(var ship in raw) { ds[ship.api_id].Update(ship); shipIds.Remove(ship.api_id); } //Remove ships that no longer exists from ds. foreach(var id in shipIds) { ds[id] = null; dsRoot.RaiseShipDataChange(id); } }
/// <summary> /// 指定した <see cref="kcsapi_ship2"/> 型の配列を使用して、<see cref="Ships"/> プロパティ値を更新します。 /// </summary> internal void Update(kcsapi_ship2[] source) { if (source.Length <= 1) { foreach (var ship in source) { var target = this.Ships[ship.api_id]; if (target == null) continue; target.Update(ship); var fleet = this.GetFleet(target.Id); if (fleet != null) fleet.State.Calculate(); } } else { this.Ships = new MemberTable<Ship>(source.Select(x => new Ship(this.homeport, x))); if (KanColleClient.Current.IsInSortie) { foreach (var id in this.evacuatedShipsIds) this.Ships[id].Situation |= ShipSituation.Evacuation; foreach (var id in this.towShipIds) this.Ships[id].Situation |= ShipSituation.Tow; } } }
/// <summary> /// 指定した <see cref="kcsapi_ship2"/> 型の配列を使用して、<see cref="Ships"/> プロパティ値を更新します。 /// </summary> internal void Update(kcsapi_ship2[] source) { if(this.Ships.SetValueRange(source, x => x.api_id, x => new Ship(this.homeport, x), (obj, dat) => obj.Update(dat), source.Length > 1)) RaiseShipsChanged(); }
/// <summary> /// 指定した <see cref="kcsapi_ship2"/> 型の配列を使用して、<see cref="Ships"/> プロパティ値を更新します。 /// </summary> internal void Update(kcsapi_ship2[] source) { if (source.Length <= 1) { foreach (var ship in source) { var target = this.Ships[ship.api_id]; if (target == null) continue; target.Update(ship); var fleet = this.GetFleet(target.Id); if (fleet != null) fleet.Calculate(); } } else { this.Ships = new MemberTable<Ship>(source.Select(x => new Ship(this.homeport, x))); } }
private void UpdateShips(kcsapi_ship2[] source) { if (source.Length <= 1) { foreach (var ship in source) { var target = this.Ships[ship.api_id]; if (target != null) target.Update(ship); } } else { this.Ships = new MemberTable<Ship>(source.Select(s => new Ship(this, s))); } }