fix throwing ObjectNotUniqueException and comparing objects
This commit is contained in:
parent
e03badef02
commit
2421f27620
@ -58,12 +58,9 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
|
||||
public int Insert(T obj, IEqualityComparer<T?>? comparer)
|
||||
{
|
||||
if (comparer == null)
|
||||
if (_collection.Contains(obj, comparer))
|
||||
{
|
||||
if (_collection.Contains(obj, comparer))
|
||||
{
|
||||
throw new ObjectNotUniqueException();
|
||||
}
|
||||
throw new ObjectNotUniqueException();
|
||||
}
|
||||
|
||||
if (Count == _maxCount) { throw new CollectionOverflowException(_collection.Count); }
|
||||
@ -74,12 +71,9 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
|
||||
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer)
|
||||
{
|
||||
if (comparer == null)
|
||||
if (_collection.Contains(obj, comparer))
|
||||
{
|
||||
if (_collection.Contains(obj, comparer))
|
||||
{
|
||||
throw new ObjectNotUniqueException();
|
||||
}
|
||||
throw new ObjectNotUniqueException(position);
|
||||
}
|
||||
|
||||
if (position < 0 || position >= Count) throw new PositionOutOfCollectionException();
|
||||
@ -87,7 +81,6 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
_collection.Insert(position, obj);
|
||||
|
||||
return position;
|
||||
|
||||
}
|
||||
|
||||
public T Remove(int position)
|
||||
|
@ -90,7 +90,7 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
foreach (T? item in _collection)
|
||||
{
|
||||
if ((comparer as IEqualityComparer<DrawningWarPlane>).Equals(obj as DrawningWarPlane, item as DrawningWarPlane))
|
||||
throw new ObjectNotUniqueException();
|
||||
throw new ObjectNotUniqueException(position);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ public class DrawiningPlaneEqutables : IEqualityComparer<DrawningWarPlane?>
|
||||
{
|
||||
EntityAirFighter _x = (EntityAirFighter) x.EntityFighter;
|
||||
EntityAirFighter _y = (EntityAirFighter) x.EntityFighter;
|
||||
|
||||
if (_x.AdditionalColor != _y.AdditionalColor)
|
||||
{
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user