файлы лабораторной
This commit is contained in:
parent
296d9b1d2a
commit
7e90426bac
@ -1,17 +1,48 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Serilog;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
namespace ProjectLainer
|
namespace ProjectLainer
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The main entry point for the application.
|
|
||||||
/// </summary>
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
|
||||||
// see https://aka.ms/applicationconfiguration.
|
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormLainerCollection());
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
||||||
|
{
|
||||||
|
Application.Run(serviceProvider.GetRequiredService<FormLainerCollection>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
|
{
|
||||||
|
string[] path = Directory.GetCurrentDirectory().Split('\\');
|
||||||
|
string pathNeed = "";
|
||||||
|
for (int i = 0; i < path.Length - 3; i++)
|
||||||
|
{
|
||||||
|
pathNeed += path[i] + "\\";
|
||||||
|
}
|
||||||
|
var configuration = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile(path: $"{pathNeed}appsettings.json", optional: false, reloadOnChange: true)
|
||||||
|
.Build();
|
||||||
|
services.AddSingleton<FormLainerCollection>().AddLogging(option =>
|
||||||
|
{
|
||||||
|
services.AddSingleton<FormLainerCollection>();
|
||||||
|
var serilogLogger = new LoggerConfiguration()
|
||||||
|
.ReadFrom.Configuration(configuration)
|
||||||
|
.CreateLogger();
|
||||||
|
services.AddLogging(x =>
|
||||||
|
{
|
||||||
|
x.SetMinimumLevel(LogLevel.Debug);
|
||||||
|
x.AddSerilog(logger: serilogLogger, dispose: true);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System.Numerics;
|
using ProjectLainer.Exceptions;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
namespace ProjectLainer.Generics
|
namespace ProjectLainer.Generics
|
||||||
{
|
{
|
||||||
@ -13,32 +14,38 @@ namespace ProjectLainer.Generics
|
|||||||
_maxCount = count;
|
_maxCount = count;
|
||||||
_places = new List<T?>(count);
|
_places = new List<T?>(count);
|
||||||
}
|
}
|
||||||
public bool Insert(T lainer)
|
|
||||||
|
public void Insert(T lainer)
|
||||||
{
|
{
|
||||||
if (_places.Count == _maxCount)
|
if (_places.Count == _maxCount)
|
||||||
{
|
{
|
||||||
return false;
|
throw new StorageOverflowException(_maxCount);
|
||||||
}
|
}
|
||||||
Insert(lainer, 0);
|
Insert(lainer, 0);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
public bool Insert(T lainer, int position)
|
|
||||||
|
public void Insert(T lainer, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position > Count || _places.Count >= _maxCount)
|
if (position >= 0 && position <= Count)
|
||||||
{
|
{
|
||||||
return false;
|
_places.Insert(position, lainer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Неверная позиция для вставки");
|
||||||
}
|
}
|
||||||
_places.Insert(position, lainer);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
public bool Remove(int position)
|
|
||||||
|
public void Remove(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count)
|
if (position < Count && position >= 0)
|
||||||
{
|
{
|
||||||
return false;
|
_places.RemoveAt(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new LainerNotFoundException(position);
|
||||||
}
|
}
|
||||||
_places.RemoveAt(position);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
public T? this[int position]
|
public T? this[int position]
|
||||||
{
|
{
|
||||||
|
15
lainer/Lainer1/appsettings.json
Normal file
15
lainer/Lainer1/appsettings.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"Serilog": {
|
||||||
|
"Using": [ "Serilog.Sinks.File" ],
|
||||||
|
"MinimumLevel": "Debug",
|
||||||
|
"WriteTo": [
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": { "path": "log.log" }
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Properties": {
|
||||||
|
"Application": "Sample"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user