Skip to content

Commit 9f8613f

Browse files
committed
Net Core - Make Initialzier properties internal
Not quite sure what the public API should look like as yet, so making internal for now.
1 parent b59c865 commit 9f8613f

File tree

2 files changed

+16
-29
lines changed

2 files changed

+16
-29
lines changed

CefSharp.Core/Initializer.cs

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ public static class Initializer
1818
{
1919
//TODO: Internal debugging only for now, needs improving if users are going to
2020
//get meaningful data from this.
21-
public static (bool Loaded, string Path, string BrowserSubProcessPath, IntPtr LibraryHandle) LibCefLoadStatus;
21+
internal static IntPtr? LibCefHandle { get; private set; }
22+
internal static bool LibCefLoaded { get; private set; }
23+
internal static string LibCefPath { get; private set; }
24+
internal static string BrowserSubProcessPath { get; private set; }
2225

2326
[ModuleInitializer]
2427
internal static void ModuleInitializer()
@@ -30,7 +33,8 @@ internal static void ModuleInitializer()
3033
{
3134
//We didn't load CEF, it was already next to our calling assembly, the
3235
//framework should load it correctly on it's own
33-
LibCefLoadStatus = (false, libCefPath, null, IntPtr.Zero);
36+
LibCefPath = libCefPath;
37+
LibCefLoaded = false;
3438
}
3539
else
3640
{
@@ -40,37 +44,21 @@ internal static void ModuleInitializer()
4044
libCefPath = Path.Combine(currentFolder, archFolder, "libcef.dll");
4145
if (File.Exists(libCefPath))
4246
{
43-
if (NativeLibrary.TryLoad(libCefPath, out IntPtr handle))
47+
LibCefLoaded = NativeLibrary.TryLoad(libCefPath, out IntPtr handle);
48+
49+
if (LibCefLoaded)
4450
{
45-
var browserSubProcessPath = Path.Combine(currentFolder, archFolder, "CefSharp.BrowserSubprocess.exe");
46-
LibCefLoadStatus = (true, libCefPath, browserSubProcessPath, handle);
51+
BrowserSubProcessPath = Path.Combine(currentFolder, archFolder, "CefSharp.BrowserSubprocess.exe");
52+
LibCefPath = libCefPath;
53+
LibCefHandle = handle;
4754
}
4855
}
4956
else
5057
{
51-
LibCefLoadStatus = (false, libCefPath, null, IntPtr.Zero);
58+
LibCefPath = libCefPath;
59+
LibCefLoaded = false;
5260
}
5361
}
54-
//var assembly = LoadCefSharpCoreRuntime();
55-
56-
//NativeLibrary.SetDllImportResolver(typeof(CefSharp.Core.CefSettingsBase).Assembly, LibCefImportResolver);
57-
58-
//CefSharpCoreRuntimeLocation = assembly.Location;
5962
}
60-
61-
//private static IntPtr LibCefImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
62-
//{
63-
// return IntPtr.Zero;
64-
//}
65-
66-
//public static Assembly LoadCefSharpCoreRuntime()
67-
//{
68-
// //Load into the same context as CefSharp.Core, if user was to create their own context then
69-
// //this should keep thing together.
70-
// var currentCtx = AssemblyLoadContext.GetLoadContext(typeof(Initializer).Assembly);
71-
72-
// var browserSubprocessDllPath = Path.Combine(Path.GetDirectoryName(typeof(Initializer).Assembly.Location), "CefSharp.Core.Runtime.dll");
73-
// return currentCtx.LoadFromAssemblyPath(browserSubprocessDllPath);
74-
//}
7563
}
7664
}

CefSharp.Core/PublicApi.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -756,10 +756,9 @@ public CefSettingsBase() : base()
756756
{
757757
if(!File.Exists(BrowserSubprocessPath))
758758
{
759-
var libCefLoadStatus = Initializer.LibCefLoadStatus;
760-
if(libCefLoadStatus.Loaded)
759+
if(Initializer.LibCefLoaded)
761760
{
762-
BrowserSubprocessPath = libCefLoadStatus.BrowserSubProcessPath;
761+
BrowserSubprocessPath = Initializer.BrowserSubProcessPath;
763762
}
764763
}
765764
}

0 commit comments

Comments
 (0)