Karamushko M.K lab8_base #12

Closed
maxKarme wants to merge 8 commits from lab8_base into lab7_base
11 changed files with 104 additions and 0 deletions
Showing only changes of commit 30a495b84d - Show all commits

View File

@ -10,5 +10,7 @@ namespace PizzeriaContracts.BindingModels
public DateTime DateDelivery { get; set; }
public string Subject { get; set; } = string.Empty;
public string Body { get; set; } = string.Empty;
public int Id => throw new NotImplementedException();
}
}

View File

@ -0,0 +1,22 @@
using PizzeriaContracts.DI;
using PizzeriaContracts.StoragesContracts;
using PizzeriaDatabaseImplement.Implements;
namespace PizzeriaDatabaseImplement
{
public class DatabaseImplementationExtension : IImplementationExtension
{
public int Priority => 2;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<IPizzaStorage, PizzaStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
}
}
}

View File

@ -44,5 +44,7 @@ namespace PizzeriaDatabaseImplement.models
Subject = Subject,
Body = Body
};
public int Id => throw new NotImplementedException();
}
}

View File

@ -0,0 +1,17 @@
using PizzeriaContracts.StoragesContracts;
namespace PizzeriaListImplement.Implements
{
internal class BackUpInfo : IBackUpInfo
{
public List<T>? GetList<T>() where T : class, new()
{
throw new NotImplementedException();
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
throw new NotImplementedException();
}
}
}

View File

@ -45,5 +45,7 @@ namespace PizzeriaListImplement.Models
SenderName = SenderName,
DateDelivery = DateDelivery,
};
public int Id => throw new NotImplementedException();
}
}

View File

@ -0,0 +1,22 @@
using PizzeriaContracts.DI;
using PizzeriaContracts.StoragesContracts;
using PizzeriaFileImplement.Implements;
namespace PizzeriaFileImplement
{
public class FileImplementationExtension : IImplementationExtension
{
public int Priority => 1;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<IPizzaStorage, PizzaStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
}
}
}

View File

@ -0,0 +1,32 @@
using PizzeriaContracts.StoragesContracts;
namespace PizzeriaFileImplement.Implements
{
public class BackUpInfo : IBackUpInfo
{
public List<T>? GetList<T>() where T : class, new()
{
var source = DataFileSingleton.GetInstance();
return (List<T>?)source.GetType().GetProperties()
.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == typeof(T))
?.GetValue(source);
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
var assembly = typeof(BackUpInfo).Assembly;
var types = assembly.GetTypes();
foreach (var type in types)
{
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
{
return type;
}
}
return null;
}
}
}

View File

@ -2,6 +2,7 @@
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.StoragesContracts;
using PizzeriaContracts.ViewModels;
using PizzeriaFileImplement.models;
namespace PizzeriaFileImplement.Implements
{

View File

@ -2,6 +2,7 @@
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.StoragesContracts;
using PizzeriaContracts.ViewModels;
using PizzeriaFileImplement.models;
namespace PizzeriaFileImplement.Implements
{

View File

@ -2,6 +2,7 @@
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.StoragesContracts;
using PizzeriaContracts.ViewModels;
using PizzeriaFileImplement.models;
namespace PizzeriaFileImplement.Implements
{

View File

@ -73,5 +73,7 @@ namespace PizzeriaFileImplement.models
new XAttribute("SenderName", SenderName),
new XAttribute("DateDelivery", DateDelivery)
);
public int Id => throw new NotImplementedException();
}
}