fix some cross-platform issues on Windows
This commit is contained in:
parent
df25f1cac0
commit
c4ea69407b
@ -13,6 +13,7 @@ using System.Text.Json.Nodes;
|
|||||||
using Mocha.Core.UI;
|
using Mocha.Core.UI;
|
||||||
using Mocha.Core.Oop;
|
using Mocha.Core.Oop;
|
||||||
using MBS.Core;
|
using MBS.Core;
|
||||||
|
|
||||||
using MBS.Core.Collections.Generic;
|
using MBS.Core.Collections.Generic;
|
||||||
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@ -74,21 +75,38 @@ public class Program : WebApplication
|
|||||||
TenantHandle th = oms.CreateTenant("super");
|
TenantHandle th = oms.CreateTenant("super");
|
||||||
oms.SelectTenant(th);
|
oms.SelectTenant(th);
|
||||||
|
|
||||||
string path = "/home/beckermj/Documents/Projects/mochapowered/mocha-dotnet/mocha-common/mocha-common/output";
|
string path;
|
||||||
|
if (System.Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||||
|
{
|
||||||
|
path = System.IO.Path.Combine(new string[]
|
||||||
|
{
|
||||||
|
System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
|
||||||
|
"Mocha"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path = "/home/beckermj/Documents/Projects/mochapowered/mocha-dotnet/mocha-common/mocha-common/output";
|
||||||
if (!System.IO.Directory.Exists(path))
|
if (!System.IO.Directory.Exists(path))
|
||||||
{
|
{
|
||||||
path = "/usr/share/mocha/system";
|
path = "/usr/share/mocha/system";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!System.IO.Directory.Exists(path))
|
if (!System.IO.Directory.Exists(path))
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("path not found: " + path);
|
Console.Error.WriteLine("path not found: " + path);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LibraryHandle lh = oms.LoadLibrary(path + "/net.alcetech.Mocha.System.mcl");
|
if (!TryLoadLibrary(oms, path, "net.alcetech.Mocha.System.mcl"))
|
||||||
oms.AddLibraryReference(lh);
|
{
|
||||||
|
return;
|
||||||
LibraryHandle lh2 = oms.LoadLibrary(path + "/net.alcetech.Mocha.Web.mcl");
|
}
|
||||||
oms.AddLibraryReference(lh2);
|
if (!TryLoadLibrary(oms, path, "net.alcetech.Mocha.Web.mcl"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// implement functions to get user IP address
|
// implement functions to get user IP address
|
||||||
oms.RegisterSystemAttributeRoutine<string>(KnownInstanceGuids.SystemAttributeRoutines.GetIPAddress, delegate (Oms oms2, OmsContext ctx2)
|
oms.RegisterSystemAttributeRoutine<string>(KnownInstanceGuids.SystemAttributeRoutines.GetIPAddress, delegate (Oms oms2, OmsContext ctx2)
|
||||||
@ -102,6 +120,25 @@ public class Program : WebApplication
|
|||||||
base.OnStartup(e);
|
base.OnStartup(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool TryLoadLibrary(Oms oms, string path, string fileName)
|
||||||
|
{
|
||||||
|
string fullyQualifiedFileName = System.IO.Path.Combine(new string[] { path, fileName });
|
||||||
|
if (!System.IO.File.Exists(fullyQualifiedFileName))
|
||||||
|
{
|
||||||
|
Console.WriteLine("file not found: {0}", fullyQualifiedFileName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LibraryHandle lh = oms.LoadLibrary(fullyQualifiedFileName);
|
||||||
|
if (lh == LibraryHandle.Empty)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
oms.AddLibraryReference(lh);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void oms_SystemRoutineExecuted(object? sender, SystemRoutineExecutedEventArgs e)
|
private void oms_SystemRoutineExecuted(object? sender, SystemRoutineExecutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.SystemRoutine.GlobalIdentifier == KnownInstanceGuids.SystemUpdateRoutines.LoginUser)
|
if (e.SystemRoutine.GlobalIdentifier == KnownInstanceGuids.SystemUpdateRoutines.LoginUser)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user