-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Ensure that System.ValueTuple.dll gets deployed * #59 - Double bond disappears when drawn vertically in the editor * #65 - 1.5 bond is too dense * #64 - Anticlockwise double bond drawing issue * #23 - Variable ring mode does not indicate ring size on first drawing * Improvements to EvaluateChemistryAllowed function * Fix bug in MOLFile export of wavy (indeterminate) bond Related work items: #71, #307, #686, #710, #717
- Loading branch information
1 parent
82ebc92
commit b9fe955
Showing
84 changed files
with
2,236 additions
and
38,805 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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// --------------------------------------------------------------------------- | ||
// Copyright (c) 2020, The .NET Foundation. | ||
// This software is released under the Apache License, Version 2.0. | ||
// The license and further copyright text can be found in the file LICENSE.md | ||
// at the root directory of the distribution. | ||
// --------------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
namespace Chem4Word | ||
{ | ||
public class AssemblyReflectionProxy : MarshalByRefObject | ||
{ | ||
private string _assemblyPath; | ||
|
||
public void LoadAssembly(String assemblyPath) | ||
{ | ||
try | ||
{ | ||
_assemblyPath = assemblyPath; | ||
Assembly.ReflectionOnlyLoadFrom(assemblyPath); | ||
} | ||
catch (FileNotFoundException) | ||
{ | ||
// Continue loading assemblies even if an assembly can not be loaded in the new AppDomain. | ||
} | ||
} | ||
|
||
public TResult Reflect<TResult>(Func<Assembly, TResult> func) | ||
{ | ||
DirectoryInfo directory = new FileInfo(_assemblyPath).Directory; | ||
|
||
// Extract filename as files will be loaded from a random dl3 cache location. | ||
FileInfo fileInfo = new FileInfo(_assemblyPath); | ||
string fileName = fileInfo.Name; | ||
|
||
ResolveEventHandler resolveEventHandler = (s, e) => | ||
{ | ||
return OnReflectionOnlyResolve(e, directory); | ||
}; | ||
|
||
AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += resolveEventHandler; | ||
|
||
var assembly = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies().FirstOrDefault(a => a.Location.EndsWith(fileName)); | ||
|
||
var result = func(assembly); | ||
|
||
AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= resolveEventHandler; | ||
|
||
return result; | ||
} | ||
|
||
private Assembly OnReflectionOnlyResolve(ResolveEventArgs args, DirectoryInfo directory) | ||
{ | ||
Assembly loadedAssembly = | ||
AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies() | ||
.FirstOrDefault( | ||
asm => string.Equals(asm.FullName, args.Name, | ||
StringComparison.OrdinalIgnoreCase)); | ||
|
||
if (loadedAssembly != null) | ||
{ | ||
return loadedAssembly; | ||
} | ||
|
||
AssemblyName assemblyName = new AssemblyName(args.Name); | ||
string dependentAssemblyFilename = Path.Combine(directory.FullName, assemblyName.Name + ".dll"); | ||
|
||
if (File.Exists(dependentAssemblyFilename)) | ||
{ | ||
return Assembly.ReflectionOnlyLoadFrom( | ||
dependentAssemblyFilename); | ||
} | ||
|
||
return Assembly.ReflectionOnlyLoad(args.Name); | ||
} | ||
} | ||
} |
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.