/// <summary> /// インスタンスをディープコピーします /// </summary> /// <returns>複製されたインスタンス</returns> public SortieReport DeepCopy() { SortieReport item = new SortieReport(); item.Map = this.Map; item.Sorties = new Dictionary<SortieReportHash, SortieReportItem>(); foreach(var x in this.Sorties) { item.Sorties[x.Key] = x.Value.DeepCopy(); } return item; }
/// <summary> /// 2つのアイテムを統合する /// </summary> /// <param name="item">統合する</param> /// <returns>統合されたアイテム></returns> public SortieReport Integrate(SortieReport item) { var result = new SortieReport(true); //キーは自分自身のを流用 result.Map = this.Map; //出撃は統合する(ディープコピー) result.Sorties = new Dictionary<SortieReportHash,SortieReportItem>(); foreach(var s in this.Sorties) { //自分自身 result.Sorties[s.Key] = s.Value.DeepCopy(); } foreach(var s in item.Sorties) { //ターゲットの統合 SortieReportItem reportItem; if(result.Sorties.TryGetValue(s.Key, out reportItem)) { reportItem = reportItem.Integrate(s.Value); } else { reportItem = s.Value.DeepCopy(); } result.Sorties[s.Key] = reportItem; } return result; }