/// <summary> /// Import a list of scores in an existing center. /// </summary> /// <param name="center">The existing center.</param> /// <param name="imported">The center to import.</param> /// <param name="mergeOptions">The merge options.</param> /// <returns>The number of scores imported.</returns> public static int Import(ScoreCenter center, ScoreCenter imported, ImportOptions mergeOptions) { int result = 0; if (imported.Scores.Items == null) { return(result); } bool isnew = center.Scores.Items != null; List <BaseScore> toImport = new List <BaseScore>(); foreach (BaseScore score in imported.Scores.Items) { BaseScore exist = center.FindScore(score.Id); if (exist != null) { // merge (or not) bool merged = exist.Merge(score, mergeOptions); if (merged) { result++; } } else { // import new if ((mergeOptions & ImportOptions.New) == ImportOptions.New) { toImport.Add(score); result++; score.SetNew(isnew); score.enable = true; } } } if (toImport.Count > 0) { if (center.Scores.Items == null) { center.Scores.Items = toImport.ToArray(); } else { center.Scores.Items = center.Scores.Items.Concat(toImport).ToArray(); } } // import parameters ExchangeManager.ImportParameters(center, imported); return(result); }