Compare commits
No commits in common. "469dc33087d9a1028fbfa1aeb2ded077e18ea7f2" and "ae6e3cac02840c82b6c98774c032142bab14737f" have entirely different histories.
469dc33087
...
ae6e3cac02
@ -1,28 +0,0 @@
|
|||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace AirBomber.Exceptions
|
|
||||||
{
|
|
||||||
[Serializable]
|
|
||||||
internal class EntityNotFoundException : ApplicationException
|
|
||||||
{
|
|
||||||
public EntityNotFoundException(int i)
|
|
||||||
: base($"Не найден объект по позиции {i}")
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public EntityNotFoundException()
|
|
||||||
: base()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public EntityNotFoundException(string Message)
|
|
||||||
: base(Message)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public EntityNotFoundException(string Message, Exception Exception)
|
|
||||||
: base(Message, Exception)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public EntityNotFoundException(SerializationInfo Info, StreamingContext Context)
|
|
||||||
: base(Info, Context)
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace AirBomber.Exceptions
|
|
||||||
{
|
|
||||||
[Serializable]
|
|
||||||
internal class StorageOverflowException : ApplicationException
|
|
||||||
{
|
|
||||||
public StorageOverflowException(int Count)
|
|
||||||
: base($"В наборе превышено допустимое количество {Count}")
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public StorageOverflowException()
|
|
||||||
: base()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public StorageOverflowException(string Message)
|
|
||||||
: base(Message)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public StorageOverflowException(string Message, Exception Exception)
|
|
||||||
: base(Message, Exception)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public StorageOverflowException(SerializationInfo Info, StreamingContext Context)
|
|
||||||
: base(Info, Context)
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
}
|
|
@ -58,7 +58,7 @@ namespace AirBomber.Generics
|
|||||||
public bool SaveData(string FileName)
|
public bool SaveData(string FileName)
|
||||||
{
|
{
|
||||||
if (_entityStorages.Count == 0)
|
if (_entityStorages.Count == 0)
|
||||||
throw new Exception("Невалиданя операция, нет данных для сохранения");
|
return false;
|
||||||
|
|
||||||
using (StreamWriter writer = new StreamWriter(FileName, false))
|
using (StreamWriter writer = new StreamWriter(FileName, false))
|
||||||
{
|
{
|
||||||
@ -80,13 +80,10 @@ namespace AirBomber.Generics
|
|||||||
|
|
||||||
public bool LoadData(string FileName)
|
public bool LoadData(string FileName)
|
||||||
{
|
{
|
||||||
if (!File.Exists(FileName))
|
|
||||||
throw new Exception("Файл не найден");
|
|
||||||
|
|
||||||
using (StreamReader reader = new StreamReader(FileName))
|
using (StreamReader reader = new StreamReader(FileName))
|
||||||
{
|
{
|
||||||
if (reader.ReadLine() != "BomberStorage")
|
if (reader.ReadLine() != "BomberStorage")
|
||||||
throw new Exception("Неверный формат данных");
|
return false;
|
||||||
|
|
||||||
_entityStorages.Clear();
|
_entityStorages.Clear();
|
||||||
|
|
||||||
@ -108,7 +105,7 @@ namespace AirBomber.Generics
|
|||||||
if (Renderer != null)
|
if (Renderer != null)
|
||||||
{
|
{
|
||||||
if ((Collection + Renderer) == -1)
|
if ((Collection + Renderer) == -1)
|
||||||
throw new Exception("Ошибка добавления в коллекцию");
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using AirBomber.Exceptions;
|
namespace AirBomber.Generics
|
||||||
|
|
||||||
namespace AirBomber.Generics
|
|
||||||
{
|
{
|
||||||
internal class SetGeneric<T>
|
internal class SetGeneric<T>
|
||||||
where T : class
|
where T : class
|
||||||
@ -29,13 +27,13 @@ namespace AirBomber.Generics
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new StorageOverflowException();
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T Entity, int Position)
|
public int Insert(T Entity, int Position)
|
||||||
{
|
{
|
||||||
if (Position >= _maxCount)
|
if (Position >= _maxCount)
|
||||||
throw new StorageOverflowException();
|
return -1;
|
||||||
|
|
||||||
if (_objects[Position] is null)
|
if (_objects[Position] is null)
|
||||||
{
|
{
|
||||||
@ -43,16 +41,13 @@ namespace AirBomber.Generics
|
|||||||
return Position;
|
return Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new StorageOverflowException();
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(int Position)
|
public bool Remove(int Position)
|
||||||
{
|
{
|
||||||
if (Position >= _maxCount)
|
if (Position >= _maxCount)
|
||||||
throw new EntityNotFoundException();
|
return false;
|
||||||
|
|
||||||
if (_objects[Position] is null)
|
|
||||||
throw new EntityNotFoundException();
|
|
||||||
|
|
||||||
_objects[Position] = default(T);
|
_objects[Position] = default(T);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user