Skip to content

Commit

Permalink
Add dependency when loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Tides committed Mar 18, 2024
1 parent 3805479 commit 752e4b0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion Obsidian/Plugins/PluginFileEntry.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Org.BouncyCastle.Crypto;
using System.Buffers;
using System.IO;
using System.IO.Compression;

Expand Down
4 changes: 4 additions & 0 deletions Obsidian/Plugins/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public async Task LoadPluginsAsync()
foreach (var canLoad in waitingForDepend.Where(x => x.IsDependency(pluginContainer.Info.Id)).ToList())
{
packedPluginProvider.InitializePlugin(canLoad);

//Add dependency to plugin
canLoad.LoadContext.AddDependency(pluginContainer.LoadContext);

this.HandlePlugin(canLoad);

waitingForDepend.Remove(canLoad);
Expand Down
2 changes: 1 addition & 1 deletion Obsidian/Plugins/PluginProviders/PackedPluginProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public sealed class PackedPluginProvider(PluginManager pluginManager, ILogger lo

var entries = await this.InitializeEntriesAsync(reader, fs);

var partialContainer = BuildPartialContainer(loadContext, path, entries, isSigValid);
var partialContainer = this.BuildPartialContainer(loadContext, path, entries, isSigValid);

//Can't load until those plugins are loaded
if (partialContainer.Info.Dependencies.Any(x => x.Required && !this.pluginManager.Plugins.Any(d => d.Info.Id == x.Id)))
Expand Down
1 change: 0 additions & 1 deletion SamplePlugin/SamplePlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<!--Can be used to move the plugin after its been packed useful when debugging ^ ^ -->
<!--<Target Name="MovePlugin" AfterTargets="PackPlugin">
<Move SourceFiles="$(PluginPublishDir)/$(PluginName).obby" DestinationFolder="{YOUR DESTINATION HERE}" />
Expand Down

0 comments on commit 752e4b0

Please sign in to comment.