-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from chuongmep/r25_unload_ass
Feat : R25 Support Unload Assembly
- Loading branch information
Showing
12 changed files
with
213 additions
and
14 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
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,48 @@ | ||
#if R25 | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Runtime.Loader; | ||
|
||
namespace RevitAddinManager.Model; | ||
|
||
class AssemblyLoadContext : System.Runtime.Loader.AssemblyLoadContext | ||
{ | ||
public AssemblyLoadContext() : base(isCollectible: true) | ||
{ | ||
} | ||
private AssemblyDependencyResolver _resolver; | ||
|
||
public AssemblyLoadContext(string pluginPath): base(isCollectible: true) | ||
{ | ||
_resolver = new AssemblyDependencyResolver(pluginPath); | ||
} | ||
|
||
protected override Assembly Load(AssemblyName assemblyName) | ||
{ | ||
string assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName); | ||
if (assemblyPath != null) | ||
{ | ||
if(assemblyPath.Contains("RevitAPI")) | ||
{ | ||
return null; | ||
} | ||
var stream = new FileStream(assemblyPath, FileMode.Open, FileAccess.Read); | ||
return LoadFromStream(stream); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
protected override IntPtr LoadUnmanagedDll(string unmanagedDllName) | ||
{ | ||
string libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName); | ||
if (libraryPath != null) | ||
{ | ||
return LoadUnmanagedDllFromPath(libraryPath); | ||
} | ||
|
||
return IntPtr.Zero; | ||
} | ||
|
||
} | ||
#endif |
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
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,24 @@ | ||
namespace Test2 | ||
{ | ||
public static class DependLib | ||
{ | ||
public static double Plus() | ||
{ | ||
return 2 + 10; | ||
} | ||
|
||
public static string? ShowDialogFolder() | ||
{ | ||
//ookii-dialogs-wpf | ||
var dialog = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog(); | ||
dialog.Description = "Select a folder"; | ||
dialog.UseDescriptionForTitle = true; | ||
dialog.ShowNewFolderButton = true; | ||
if (dialog.ShowDialog() == true) | ||
{ | ||
return dialog.SelectedPath; | ||
} | ||
return null; | ||
} | ||
} | ||
} |
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>net48</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>latest</LangVersion> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<UseWpf>true</UseWpf> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="$(Configuration.Contains('Debug'))"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<DefineConstants>$(DefineConstants);DEBUG</DefineConstants> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="$(Configuration.Contains('Release'))"> | ||
<Optimize>true</Optimize> | ||
<DebugType>none</DebugType> | ||
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<Version>$(RevitVersion)</Version> | ||
<EnableDynamicLoading>true</EnableDynamicLoading> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<Description>A Project Support for developer in revit </Description> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" /> | ||
<PackageReference Include="coverlet.collector" Version="3.1.0" /> | ||
<PackageReference Include="Chuongmep.Revit.Api.RevitAPI" Version="$(RevitVersion).*" /> | ||
<PackageReference Include="Chuongmep.Revit.Api.RevitAPIUI" Version="$(RevitVersion).*" /> | ||
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="PresentationFramework" /> | ||
</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