mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
wire up Autofac
This commit is contained in:
parent
3873262d99
commit
345bb2f27c
2 changed files with 40 additions and 12 deletions
|
|
@ -27,9 +27,12 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac" Version="4.9.2" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.4.0" />
|
||||
<PackageReference Include="LibGit2Sharp" Version="0.26.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
|
||||
<PackageReference Include="Microsoft.DotNet.Analyzers.Compatibility" Version="0.2.12-alpha" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,24 +1,49 @@
|
|||
namespace FilterLists.Agent
|
||||
using System;
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace FilterLists.Agent
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
//TODO: get raw list urls and IDs
|
||||
//TODO: foreach list, download and persist raw list to disk with standardized name and overwriting the previous version
|
||||
//TODO: git add .
|
||||
//TODO: git commit
|
||||
//TODO: foreach list, upsert into MariaDB Rules table https://stackoverflow.com/questions/15271202/mysql-load-data-infile-with-on-duplicate-key-update
|
||||
|
||||
private static IServiceProvider _serviceProvider;
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
// get raw list urls and IDs
|
||||
RegisterServices();
|
||||
|
||||
// foreach
|
||||
//var service = _serviceProvider.GetService<IDemoService>();
|
||||
//service.DoSomething();
|
||||
|
||||
// download raw list
|
||||
DisposeServices();
|
||||
}
|
||||
|
||||
// persist raw list to disk with standardized name and overwriting the previous version
|
||||
private static void RegisterServices()
|
||||
{
|
||||
var containerBuilder = new ContainerBuilder();
|
||||
//builder.RegisterType<DemoService>().As<IDemoService>();
|
||||
containerBuilder.Populate(new ServiceCollection());
|
||||
var container = containerBuilder.Build();
|
||||
_serviceProvider = new AutofacServiceProvider(container);
|
||||
}
|
||||
|
||||
// git add .
|
||||
|
||||
// git commit
|
||||
|
||||
// foreach
|
||||
|
||||
// upsert into MariaDB Rules table https://stackoverflow.com/questions/15271202/mysql-load-data-infile-with-on-duplicate-key-update
|
||||
private static void DisposeServices()
|
||||
{
|
||||
switch (_serviceProvider)
|
||||
{
|
||||
case null:
|
||||
return;
|
||||
case IDisposable disposableServiceProvider:
|
||||
disposableServiceProvider.Dispose();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue