Compare commits

..

No commits in common. "469dc33087d9a1028fbfa1aeb2ded077e18ea7f2" and "ae6e3cac02840c82b6c98774c032142bab14737f" have entirely different histories.

4 changed files with 8 additions and 72 deletions

View File

@ -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)
{ }
}
}

View File

@ -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)
{ }
}
}

View File

@ -58,7 +58,7 @@ namespace AirBomber.Generics
public bool SaveData(string FileName)
{
if (_entityStorages.Count == 0)
throw new Exception("Невалиданя операция, нет данных для сохранения");
return false;
using (StreamWriter writer = new StreamWriter(FileName, false))
{
@ -80,13 +80,10 @@ namespace AirBomber.Generics
public bool LoadData(string FileName)
{
if (!File.Exists(FileName))
throw new Exception("Файл не найден");
using (StreamReader reader = new StreamReader(FileName))
{
if (reader.ReadLine() != "BomberStorage")
throw new Exception("Неверный формат данных");
return false;
_entityStorages.Clear();
@ -108,7 +105,7 @@ namespace AirBomber.Generics
if (Renderer != null)
{
if ((Collection + Renderer) == -1)
throw new Exception("Ошибка добавления в коллекцию");
return false;
}
}

View File

@ -1,6 +1,4 @@
using AirBomber.Exceptions;
namespace AirBomber.Generics
namespace AirBomber.Generics
{
internal class SetGeneric<T>
where T : class
@ -29,13 +27,13 @@ namespace AirBomber.Generics
return i;
}
throw new StorageOverflowException();
return -1;
}
public int Insert(T Entity, int Position)
{
if (Position >= _maxCount)
throw new StorageOverflowException();
return -1;
if (_objects[Position] is null)
{
@ -43,16 +41,13 @@ namespace AirBomber.Generics
return Position;
}
throw new StorageOverflowException();
return -1;
}
public bool Remove(int Position)
{
if (Position >= _maxCount)
throw new EntityNotFoundException();
if (_objects[Position] is null)
throw new EntityNotFoundException();
return false;
_objects[Position] = default(T);
return true;