lab 8 full

This commit is contained in:
parap 2023-05-09 00:37:14 +04:00
parent 30a495b84d
commit 100685931c
5 changed files with 18 additions and 9 deletions

View File

@ -15,11 +15,6 @@ namespace Pizzeria
{ {
internal static class Program internal static class Program
{ {
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread] [STAThread]
static void Main() static void Main()
{ {
@ -30,7 +25,7 @@ namespace Pizzeria
InitDependency(); InitDependency();
try try
{ {
var mailSender = _serviceProvider.GetService<AbstractMailWorker>(); var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
mailSender?.MailConfig(new MailConfigBindingModel mailSender?.MailConfig(new MailConfigBindingModel
{ {
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty, MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
@ -49,7 +44,7 @@ namespace Pizzeria
var logger = DependencyManager.Instance.Resolve<ILogger>(); var logger = DependencyManager.Instance.Resolve<ILogger>();
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé"); logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
} }
Application.Run(_serviceProvider.GetRequiredService<FormMain>()); Application.Run(DependencyManager.Instance.Resolve<FormMain>());
} }
private static void InitDependency() private static void InitDependency()
{ {
@ -76,6 +71,8 @@ namespace Pizzeria
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>(); DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>(); DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true); DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
DependencyManager.Instance.RegisterType<FormMain>(); DependencyManager.Instance.RegisterType<FormMain>();
DependencyManager.Instance.RegisterType<FormComponent>(); DependencyManager.Instance.RegisterType<FormComponent>();
DependencyManager.Instance.RegisterType<FormComponents>(); DependencyManager.Instance.RegisterType<FormComponents>();
@ -90,7 +87,6 @@ namespace Pizzeria
DependencyManager.Instance.RegisterType<FormImplementers>(); DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormMails>(); DependencyManager.Instance.RegisterType<FormMails>();
} }
private static void MailCheck(object obj) => private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
} }
} }

View File

@ -17,6 +17,7 @@ namespace PizzeriaContracts.ViewModels
public string PizzaName { get; set; } = string.Empty; public string PizzaName { get; set; } = string.Empty;
[Column("Цена", width: 100)] [Column("Цена", width: 100)]
public double Price { get; set; } public double Price { get; set; }
[Column(visible: false)]
public Dictionary<int, (IComponentModel, int)> PizzaComponents public Dictionary<int, (IComponentModel, int)> PizzaComponents
{ {
get; get;

View File

@ -21,4 +21,8 @@
<ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" /> <ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" />
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project> </Project>

View File

@ -11,4 +11,8 @@
<ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" /> <ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" />
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project> </Project>

View File

@ -11,4 +11,8 @@
<ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" /> <ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" />
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project> </Project>