-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split automation into separate module
- Loading branch information
1 parent
7dd7886
commit f9c24ee
Showing
38 changed files
with
236 additions
and
208 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Autofac; | ||
|
||
namespace LenovoLegionToolkit.Lib.Automation | ||
{ | ||
public class DIContainerModule : Module | ||
{ | ||
protected override void Load(ContainerBuilder builder) | ||
{ | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
LenovoLegionToolkit.Lib.Automation/LenovoLegionToolkit.Lib.Automation.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0-windows</TargetFramework> | ||
<RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Autofac" Version="6.4.0" /> | ||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /> | ||
<PackageReference Include="NeoSmart.AsyncLock" Version="3.2.1" /> | ||
<PackageReference Include="Ben.Demystifier" Version="0.4.1" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\LenovoLegionToolkit.Lib\LenovoLegionToolkit.Lib.csproj" /> | ||
</ItemGroup> | ||
</Project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using Autofac; | ||
|
||
namespace LenovoLegionToolkit.Lib | ||
{ | ||
public class DIContainer | ||
{ | ||
private static IContainer? _container; | ||
|
||
public static void Initialize(params Module[] modules) | ||
{ | ||
var cb = new ContainerBuilder(); | ||
|
||
foreach (var module in modules) | ||
cb.RegisterModule(module); | ||
|
||
_container = cb.Build(); | ||
} | ||
|
||
public static T Resolve<T>() where T : notnull | ||
{ | ||
if (_container == null) | ||
throw new InvalidOperationException("DIContainer must be initialized first"); | ||
return _container.Resolve<T>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Autofac; | ||
using LenovoLegionToolkit.Lib.Controllers; | ||
using LenovoLegionToolkit.Lib.Extensions; | ||
using LenovoLegionToolkit.Lib.Features; | ||
using LenovoLegionToolkit.Lib.Listeners; | ||
using LenovoLegionToolkit.Lib.Utils; | ||
|
||
namespace LenovoLegionToolkit.Lib | ||
{ | ||
public class DIContainerModule : Module | ||
{ | ||
protected override void Load(ContainerBuilder builder) | ||
{ | ||
builder.Register<AlwaysOnUSBFeature>(); | ||
builder.Register<BatteryFeature>(); | ||
builder.Register<FlipToStartFeature>(); | ||
builder.Register<FnLockFeature>(); | ||
builder.Register<HybridModeFeature>(); | ||
builder.Register<OverDriveFeature>(); | ||
builder.Register<PowerModeFeature>(); | ||
builder.Register<RefreshRateFeature>(); | ||
builder.Register<TouchpadLockFeature>(); | ||
|
||
builder.Register<PowerModeListener>(true); | ||
builder.Register<PowerAdapterListener>(true); | ||
builder.Register<DisplayConfigurationListener>(true); | ||
builder.Register<SpecialKeyListener>(true); | ||
|
||
builder.Register<GPUController>(); | ||
builder.Register<CPUBoostModeController>(); | ||
|
||
builder.Register<UpdateChecker>(); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
LenovoLegionToolkit.Lib/Extensions/ContainerBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Autofac; | ||
|
||
namespace LenovoLegionToolkit.Lib.Extensions | ||
{ | ||
public static class ContainerBuilderExtensions | ||
{ | ||
public static void Register<T>(this ContainerBuilder cb, bool autoCreate = false) where T : notnull | ||
{ | ||
var r = cb.RegisterType<T>().AsSelf().AsImplementedInterfaces().SingleInstance(); | ||
|
||
if (autoCreate) | ||
r.AutoActivate(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0-windows</TargetFramework> | ||
<RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /> | ||
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="6.0.1" /> | ||
<PackageReference Include="System.Management" Version="6.0.0" /> | ||
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0" /> | ||
<PackageReference Include="NeoSmart.AsyncLock" Version="3.2.1" /> | ||
<PackageReference Include="Ben.Demystifier" Version="0.4.1" /> | ||
<PackageReference Include="NvAPIWrapper.Net" Version="0.8.1.101" /> | ||
<PackageReference Include="Octokit" Version="0.51.0" /> | ||
<PackageReference Include="TaskScheduler" Version="2.10.1" /> | ||
<PackageReference Include="WindowsDisplayAPI" Version="1.3.0.13" /> | ||
</ItemGroup> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0-windows</TargetFramework> | ||
<RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Autofac" Version="6.4.0" /> | ||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /> | ||
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="6.0.1" /> | ||
<PackageReference Include="System.Management" Version="6.0.0" /> | ||
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0" /> | ||
<PackageReference Include="NeoSmart.AsyncLock" Version="3.2.1" /> | ||
<PackageReference Include="Ben.Demystifier" Version="0.4.1" /> | ||
<PackageReference Include="NvAPIWrapper.Net" Version="0.8.1.101" /> | ||
<PackageReference Include="Octokit" Version="0.51.0" /> | ||
<PackageReference Include="TaskScheduler" Version="2.10.1" /> | ||
<PackageReference Include="WindowsDisplayAPI" Version="1.3.0.13" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.