/// <summary> /// Modifies this instance to include missing values identified in <paramref name="others"/> /// </summary> /// <param name="others"></param> /// <returns></returns> public CommandLineObjectPickerArgumentValue Merge(IEnumerable <CommandLineObjectPickerArgumentValue> others) { foreach (var other in others) { if (other.Index != Index || other.RawValue != RawValue) { throw new ArgumentException("Merge only arguments of the same object"); } Type = Type ?? other.Type; Database = Database ?? other.Database; Table = Table ?? other.Table; //do we have any? yet if (DatabaseEntities == null || !DatabaseEntities.Any()) //no { DatabaseEntities = other.DatabaseEntities; //use theirs } else if (other.DatabaseEntities != null && other.DatabaseEntities.Any()) { throw new Exception("Did not know what set to pick during merge. Both had DatabaseEntitites"); } } return(this); }