-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split the package, added Models and DI package
- Loading branch information
Showing
34 changed files
with
1,110 additions
and
767 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -17,22 +17,17 @@ jobs: | |
- uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup .NET 6 | ||
uses: actions/setup-dotnet@master | ||
with: | ||
dotnet-version: 6.x.x | ||
|
||
- name: Setup .NET 7 | ||
|
||
- name: Setup .NET 8 | ||
uses: actions/setup-dotnet@master | ||
with: | ||
dotnet-version: 7.x.x | ||
dotnet-version: 8.x.x | ||
|
||
- run: dotnet pack -c Release src/Bannerlord.ModuleManager -p:VersionOverride=$(git rev-list --no-merges --count master) -p:PackAsSource=false -o ./packages | ||
- run: dotnet pack -c Release src/Bannerlord.ModuleManager -p:VersionOverride=$(git rev-list --no-merges --count master) -o ./packages | ||
|
||
- run: dotnet pack -c Release src/Bannerlord.ModuleManager -p:VersionOverride=$(git rev-list --no-merges --count master) -p:PackAsSource=true -o ./packages | ||
- run: dotnet pack -c Release src/Bannerlord.ModuleManager.Source -p:VersionOverride=$(git rev-list --no-merges --count master) -o ./packages | ||
|
||
- run: dotnet pack -c Release src/Bannerlord.ModuleManager.Native -p:VersionOverride=$(git rev-list --no-merges --count master) -o ./packages | ||
- run: dotnet pack -c Release src/Bannerlord.ModuleManager.DependencyInjection -p:VersionOverride=$(git rev-list --no-merges --count master) -o ./packages | ||
|
||
- name: Push to NuGet | ||
run: dotnet nuget push "./packages/*.nupkg" -k ${{secrets.NUGET_API_KEY}} -s https://www.nuget.org --skip-duplicate | ||
|
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 |
---|---|---|
|
@@ -19,10 +19,10 @@ jobs: | |
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup .NET 7 | ||
- name: Setup .NET 8 | ||
uses: actions/setup-dotnet@master | ||
with: | ||
dotnet-version: 7.x.x | ||
dotnet-version: 8.x.x | ||
|
||
- uses: actions/[email protected] | ||
with: | ||
|
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
39 changes: 39 additions & 0 deletions
39
...ord.ModuleManager.DependencyInjection/Bannerlord.ModuleManager.DependencyInjection.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,39 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<LangVersion>10.0</LangVersion> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<!--NuGet Package--> | ||
<PropertyGroup> | ||
<Authors>BUTR</Authors> | ||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageIcon>Butter.png</PackageIcon> | ||
<PackageProjectUrl>https://github.com/BUTR/Bannerlord.ModuleManager</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/BUTR/Bannerlord.ModuleManager.git</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<PackageId>Bannerlord.ModuleManager.DependencyInjection</PackageId> | ||
<PackageDescription>DI for managing Mount & Blade 2: Bannerlord Module dependencies.</PackageDescription> | ||
<Title>Bannerlord ModuleManager DependencyInjection</Title> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="../../resources/Butter.png" Pack="true" PackagePath="" /> | ||
</ItemGroup> | ||
<!--NuGet Package--> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Bannerlord.ModuleManager\Bannerlord.ModuleManager.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
32 changes: 32 additions & 0 deletions
32
src/Bannerlord.ModuleManager.DependencyInjection/IModuleManager.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,32 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Bannerlord.ModuleManager.DependencyInjection; | ||
|
||
public interface IModuleManager | ||
{ | ||
IList<ModuleInfoExtended> Sort(IReadOnlyCollection<ModuleInfoExtended> source); | ||
IList<ModuleInfoExtended> Sort(IReadOnlyCollection<ModuleInfoExtended> source, ModuleSorterOptions options); | ||
|
||
bool AreDependenciesPresent(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended module); | ||
|
||
IList<ModuleInfoExtended> GetDependencies(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended module); | ||
IList<ModuleInfoExtended> GetDependencies(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended module, ModuleSorterOptions options); | ||
|
||
IList<ModuleIssue> ValidateModule(IReadOnlyList<ModuleInfoExtended> modules, ModuleInfoExtended targetModule, IModuleManagerModuleViewModel provider); | ||
IList<ModuleIssue> ValidateLoadOrder(IReadOnlyList<ModuleInfoExtended> modules, ModuleInfoExtended targetModule); | ||
|
||
void EnableModule(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended targetModule, IModuleManagerModuleViewModel provider); | ||
void DisableModule(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended targetModule, IModuleManagerModuleViewModel provider); | ||
|
||
ModuleInfoExtended? GetModuleInfo(string xml); | ||
|
||
SubModuleInfoExtended? GetSubModuleInfo(string xml); | ||
|
||
ApplicationVersion ParseApplicationVersion(string value); | ||
int CompareVersions(ApplicationVersion x, ApplicationVersion y); | ||
|
||
IList<DependentModuleMetadata> GetDependenciesAll(ModuleInfoExtended moduleInfoExtended); | ||
IList<DependentModuleMetadata> GetDependenciesLoadBeforeThis(ModuleInfoExtended moduleInfoExtended); | ||
IList<DependentModuleMetadata> GetDependenciesLoadAfterThis(ModuleInfoExtended moduleInfoExtended); | ||
IList<DependentModuleMetadata> GetDependenciesIncompatibles(ModuleInfoExtended moduleInfoExtended); | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Bannerlord.ModuleManager.DependencyInjection/IModuleManagerModuleViewModel.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,10 @@ | ||
namespace Bannerlord.ModuleManager.DependencyInjection; | ||
|
||
public interface IModuleManagerModuleViewModel | ||
{ | ||
bool GetSelected(string moduleId); | ||
void SetSelected(string moduleId, bool value); | ||
|
||
bool GetDisabled(string moduleId); | ||
void SetDisabled(string moduleId, bool value); | ||
} |
74 changes: 74 additions & 0 deletions
74
src/Bannerlord.ModuleManager.DependencyInjection/ModuleManager.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,74 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Xml; | ||
|
||
namespace Bannerlord.ModuleManager.DependencyInjection; | ||
|
||
public class ModuleManager : IModuleManager | ||
{ | ||
public IList<ModuleInfoExtended> Sort(IReadOnlyCollection<ModuleInfoExtended> source) => | ||
ModuleSorter.Sort(source); | ||
public IList<ModuleInfoExtended> Sort(IReadOnlyCollection<ModuleInfoExtended> source, ModuleSorterOptions options) => | ||
ModuleSorter.Sort(source, options); | ||
|
||
public bool AreDependenciesPresent(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended module) => | ||
ModuleUtilities.AreDependenciesPresent(modules, module); | ||
|
||
public IList<ModuleInfoExtended> GetDependencies(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended module) => | ||
ModuleUtilities.GetDependencies(modules, module).ToList(); | ||
public IList<ModuleInfoExtended> GetDependencies(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended module, ModuleSorterOptions options) => | ||
ModuleUtilities.GetDependencies(modules, module, options).ToList(); | ||
|
||
|
||
public IList<ModuleIssue> ValidateModule(IReadOnlyList<ModuleInfoExtended> modules, ModuleInfoExtended targetModule, IModuleManagerModuleViewModel provider) => | ||
ModuleUtilities.ValidateModule(modules, targetModule, x => provider.GetSelected(x.Id)).ToList(); | ||
|
||
public IList<ModuleIssue> ValidateLoadOrder(IReadOnlyList<ModuleInfoExtended> modules, ModuleInfoExtended targetModule) => | ||
ModuleUtilities.ValidateLoadOrder(modules, targetModule).ToList(); | ||
|
||
public void EnableModule(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended targetModule, IModuleManagerModuleViewModel provider) => | ||
ModuleUtilities.EnableModule(modules, targetModule, x => provider.GetSelected(x.Id), (x, y) => provider.SetSelected(x.Id, y), x => provider.GetDisabled(x.Id), (x, y) => provider.SetDisabled(x.Id, y)); | ||
|
||
public void DisableModule(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended targetModule, IModuleManagerModuleViewModel provider) => | ||
ModuleUtilities.DisableModule(modules, targetModule, x => provider.GetSelected(x.Id), (x, y) => provider.SetSelected(x.Id, y), x => provider.GetDisabled(x.Id), (x, y) => provider.SetDisabled(x.Id, y)); | ||
|
||
public ModuleInfoExtended? GetModuleInfo(string xml) | ||
{ | ||
try | ||
{ | ||
var doc = new XmlDocument(); | ||
doc.LoadXml(xml); | ||
return ModuleInfoExtended.FromXml(doc); | ||
} | ||
catch { return null; } | ||
} | ||
|
||
public SubModuleInfoExtended? GetSubModuleInfo(string xml) | ||
{ | ||
try | ||
{ | ||
var doc = new XmlDocument(); | ||
doc.LoadXml(xml); | ||
return SubModuleInfoExtended.FromXml(doc); | ||
} | ||
catch { return null; } | ||
} | ||
|
||
public ApplicationVersion ParseApplicationVersion(string value) => | ||
ApplicationVersion.TryParse(value, out var x) ? x : ApplicationVersion.Empty; | ||
|
||
public int CompareVersions(ApplicationVersion x, ApplicationVersion y) => | ||
new ApplicationVersionComparer().Compare(x, y); | ||
|
||
public IList<DependentModuleMetadata> GetDependenciesAll(ModuleInfoExtended moduleInfoExtended) => | ||
moduleInfoExtended.DependenciesAllDistinct().ToArray(); | ||
|
||
public IList<DependentModuleMetadata> GetDependenciesLoadBeforeThis(ModuleInfoExtended moduleInfoExtended) => | ||
moduleInfoExtended.DependenciesLoadBeforeThisDistinct().ToArray(); | ||
|
||
public IList<DependentModuleMetadata> GetDependenciesLoadAfterThis(ModuleInfoExtended moduleInfoExtended) => | ||
moduleInfoExtended.DependenciesLoadAfterThisDistinct().ToArray(); | ||
|
||
public IList<DependentModuleMetadata> GetDependenciesIncompatibles(ModuleInfoExtended moduleInfoExtended) => | ||
moduleInfoExtended.DependenciesIncompatiblesDistinct().ToArray(); | ||
} |
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.