/// <summary> /// Try to get an extension. /// </summary> /// <param name="ext">The extension obtained. If the return value is false, then this is null.</param> /// <typeparam name="T">The extension type to check for.</typeparam> /// <returns>Whether or not the extension was found. If false, the extension was not found.</returns> public bool TryGetExtension <T>(out T ext) where T : NativeExtension <EGL> { ext = LibraryLoader <EGL> .Load <T>(this); return(ext != null); }
static ffmpeg() { var loadedLibraries = new Dictionary <string, IntPtr>(); GetOrLoadLibrary = (name, version) => { var key = $"{name}{version}"; if (loadedLibraries.TryGetValue(key, out var ptr)) { return(ptr); } lock (SyncRoot) { if (loadedLibraries.TryGetValue(key, out ptr)) { return(ptr); } ptr = LibraryLoader.LoadNativeLibraryUsingPlatformNamingConvention(RootPath, name, version); if (ptr == IntPtr.Zero) { throw new DllNotFoundException($"Unable to load DLL '{name}.{version}': The specified module could not be found."); } loadedLibraries.Add(key, ptr); } return(ptr); }; }
protected override IntPtr GetJitAddress() { string jitLibraryName = string.Empty; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { jitLibraryName = "clrjit.dll"; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { jitLibraryName = "libclrjit.so"; } else { jitLibraryName = "libclrjit.dylib"; } LibraryLoader?defaultLoader = LibraryLoader.GetPlatformDefaultLoader(); IntPtr libAddress = defaultLoader.LoadNativeLibrary(jitLibraryName); IntPtr getJitAddress = defaultLoader.LoadFunctionPointer(libAddress, "getJit"); GetJitDelegate getJit = Marshal.GetDelegateForFunctionPointer <GetJitDelegate>(getJitAddress); IntPtr jitAddress = getJit(); return(jitAddress); }
public AACDecoder(string libraryPath, TransportType transportFmt, AudioObjectType audioObjectType, uint nrOfLayers) { if (!File.Exists(libraryPath)) { throw new IOException("Library not found."); } // Open library _handle = LibraryLoader.DlOpen(libraryPath, 0); // Get function pointers symbols IntPtr symAacDecoder_Open = LibraryLoader.DlSym(_handle, "aacDecoder_Open"); IntPtr symAacDecoder_ConfigRaw = LibraryLoader.DlSym(_handle, "aacDecoder_ConfigRaw"); IntPtr sysAacDecoder_GetStreamInfo = LibraryLoader.DlSym(_handle, "aacDecoder_GetStreamInfo"); IntPtr sysAacDecoder_Fill = LibraryLoader.DlSym(_handle, "aacDecoder_Fill"); IntPtr sysAacDecoder_DecodeFrame = LibraryLoader.DlSym(_handle, "aacDecoder_DecodeFrame"); IntPtr sysAacDecoder_Close = LibraryLoader.DlSym(_handle, "aacDecoder_Close"); // Get delegates for the function pointers _aacDecoder_Open = Marshal.GetDelegateForFunctionPointer <aacDecoder_Open>(symAacDecoder_Open); _aacDecoder_ConfigRaw = Marshal.GetDelegateForFunctionPointer <aacDecoder_ConfigRaw>(symAacDecoder_ConfigRaw); _aacDecoder_Fill = Marshal.GetDelegateForFunctionPointer <aacDecoder_Fill>(sysAacDecoder_Fill); _aacDecoder_DecodeFrame = Marshal.GetDelegateForFunctionPointer <aacDecoder_DecodeFrame>(sysAacDecoder_DecodeFrame); _aacDecoder_Close = Marshal.GetDelegateForFunctionPointer <aacDecoder_Close>(sysAacDecoder_Close); _decoder = _aacDecoder_Open((int)transportFmt, nrOfLayers); _audioObjectType = audioObjectType; }
static ffmpeg() { var loadedLibraries = new Dictionary <string, IntPtr>(); GetOrLoadLibrary = (name, version) => { var key = $"{name}{version}"; if (loadedLibraries.TryGetValue(key, out var ptr)) { return(ptr); } lock (SyncRoot) { if (loadedLibraries.TryGetValue(key, out ptr)) { return(ptr); } ptr = LibraryLoader.LoadNativeLibraryUsingPlatformNamingConvention(RootPath, name, version); loadedLibraries.Add(key, ptr); } return(ptr); }; }
static void RunRepl() { WrenVM vm = new WrenVM(); LibraryLoader.LoadLibraries(vm); Console.WriteLine("-- wren v0.0.0"); string line = ""; for (; ;) { Console.Write("> "); line += Console.ReadLine() + "\n"; if (OpenBrackets(line) > 0) { continue; } // TODO: Handle failure. vm.Interpret("Prompt", "Prompt", line); line = ""; } }
static ffmpeg() { var loadedLibraries = new Dictionary <string, IntPtr>(); GetOrLoadLibrary = (name, version) => { var key = $"{name}{version}"; if (loadedLibraries.TryGetValue(key, out var ptr)) { return(ptr); } ptr = LibraryLoader.LoadNativeLibraryUsingPlatformNamingConvention(abs_path, name, version); loadedLibraries.Add(key, ptr); return(ptr); }; CloseLibrary = (name, version) => { var key = $"{name}{version}"; bool ret = false; if (loadedLibraries.TryGetValue(key, out var ptr)) { ret = LibraryLoader.UnloadLibrary(ptr); loadedLibraries.Remove(key); } return(ret); }; }
static SoundIO() { _handle = LibraryLoader.Load(typeof(SoundIO)); if (BitConverter.IsLittleEndian) { SoundIoFormatS16NE = (uint)SoundIoFormat.SoundIoFormatS16LE; SoundIoFormatU16NE = (uint)SoundIoFormat.SoundIoFormatU16LE; SoundIoFormatS24NE = (uint)SoundIoFormat.SoundIoFormatS24LE; SoundIoFormatU24NE = (uint)SoundIoFormat.SoundIoFormatU24LE; SoundIoFormatS32NE = (uint)SoundIoFormat.SoundIoFormatS32LE; SoundIoFormatU32NE = (uint)SoundIoFormat.SoundIoFormatU32LE; SoundIoFormatFloat32NE = (uint)SoundIoFormat.SoundIoFormatFloat32LE; SoundIoFormatFloat64NE = (uint)SoundIoFormat.SoundIoFormatFloat64LE; SoundIoFormatS16FE = (uint)SoundIoFormat.SoundIoFormatS16BE; SoundIoFormatU16FE = (uint)SoundIoFormat.SoundIoFormatU16BE; SoundIoFormatS24FE = (uint)SoundIoFormat.SoundIoFormatS24BE; SoundIoFormatU24FE = (uint)SoundIoFormat.SoundIoFormatU24BE; SoundIoFormatS32FE = (uint)SoundIoFormat.SoundIoFormatS32BE; SoundIoFormatU32FE = (uint)SoundIoFormat.SoundIoFormatU32BE; SoundIoFormatFloat32FE = (uint)SoundIoFormat.SoundIoFormatFloat32BE; SoundIoFormatFloat64FE = (uint)SoundIoFormat.SoundIoFormatFloat64BE; } }
public MainWindow() { InitLog(); Log.Information("Service starting..."); CefSharp.CefSettings settings = new CefSharp.CefSettings(); settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\CEF"; CefSharp.Cef.Initialize(settings); InitializeComponent(); _libLoader = new LibraryLoader(); _libLoader.Init(); _mtBus = new MTBus(); _orderCache = new OrderCacheValidator(); _orderCache.DetectOrder += OrderCacheOnDetectOrder; Browser.FrameLoadEnd += WebBrowserFrameLoadEnded; this.Closing += OnClosing; _timeScheduler = new TimeSchedulerService(TimeSpan.FromMinutes(15)); _timeScheduler.Work += TimeSchedulerOnWork; _timeScheduler.Start(); Log.Information("Service started"); }
static ffmpeg() { var loadedLibraries = new Dictionary <string, IntPtr>(); GetOrLoadLibrary = name => { if (loadedLibraries.TryGetValue(name, out var ptr)) { return(ptr); } lock (SyncRoot) { if (loadedLibraries.TryGetValue(name, out ptr)) { return(ptr); } ptr = LoadLibrary(name); loadedLibraries.Add(name, ptr); } return(ptr); }; switch (LibraryLoader.GetPlatformId()) { case PlatformID.MacOSX: EAGAIN = 35; break; default: EAGAIN = 11; break; } }
private static IntPtr LoadLibrary(string libraryName, bool throwException) { if (LoadedLibraries.TryGetValue(libraryName, out var ptr)) { return(ptr); } lock (SyncRoot) { if (LoadedLibraries.TryGetValue(libraryName, out ptr)) { return(ptr); } var dependencies = LibraryDependenciesMap[libraryName]; dependencies.Where(n => !LoadedLibraries.ContainsKey(n) && !n.Equals(libraryName)) .ToList() .ForEach(n => LoadLibrary(n, false)); var version = LibraryVersionMap[libraryName]; ptr = LibraryLoader.LoadNativeLibrary(RootPath, libraryName, version); if (ptr != IntPtr.Zero) { LoadedLibraries.Add(libraryName, ptr); } else if (throwException) { throw new DllNotFoundException( $"Unable to load DLL '{libraryName}.{version} under {RootPath}': The specified module could not be found."); } return(ptr); } }
public static void InitEngine() { LibraryLoader.Load(new LibraryConfig() { Linux64 = new LibraryContent[] { new LibraryContent("cimgui.so", () => GetEmbedResourceWithMatchName((name) => name.Contains("cimgui") && name.Contains("linux") && name.Contains("64"))), }, Win32 = new LibraryContent[] { new LibraryContent("cimgui.dll", () => GetEmbedResourceWithMatchName((name) => name.Contains("cimgui") && name.Contains("win") && name.Contains("86"))), }, Win64 = new LibraryContent[] { new LibraryContent("cimgui.dll", () => GetEmbedResourceWithMatchName((name) => name.Contains("cimgui") && name.Contains("win") && name.Contains("64"))), }, Mac64 = new LibraryContent[] { new LibraryContent("cimgui.dylib", () => GetEmbedResourceWithMatchName((name) => name.Contains("cimgui") && name.Contains("osx") && name.Contains("64"))), }, }); }
public static Vk GetApi() { var sym = new VkLoader(PlatformLoaderBase.PlatformLoader); var ret = LibraryLoader <Vk> .Load(new VulkanLibraryNameContainer(), sym); sym.Vulkan = ret; return(ret); }
public void Start() { LibraryLoader.loadMoveLibrary(); List <Creature> creatures1 = LibraryLoader.loadTestCreatures(); List <Creature> creatures2 = LibraryLoader.loadTestCreatures(); setup(new Pair <int, int>(1, 0), new Team(creatures1), new Team(creatures2)); }
public bool TryGetExtension <T>(out T ext) where T : NativeExtension <Vk> { ext = LibraryLoader <Vk> .Load <T> (this, SearchPaths, _extLoader ??= new VkLoader(this, PlatformLoaderBase.PlatformLoader)); return(ext != null); }
/// <summary> /// Create a HarmonyLibrary from a subset of the given byte array, which should contain the bytes of /// an unmanaged EXE or an unmanaged DLL. /// </summary> /// <param name="rawDll">An array of bytes that contains the EXE or DLL to load.</param> /// <param name="offset">Where within the raw byte array the actual EXE or DLL starts.</param> /// <param name="length">The length of the EXE or DLL bytes starting at the given offset in the array.</param> /// <param name="name">(optional) The name of the library we're loading (to be used when resolving other libraries).</param> /// <param name="loadFlags">(optional) Flags to control how this loading is performed.</param> /// <param name="otherLibraries">(optional) Any other HarmonyLibraries to use when resolving this library's imports.</param> /// <returns>A HarmonyLibrary instance.</returns> /// <throws cref="LoadFailedException">Thrown when the library cannot be loaded (if, for example, it is corrupt /// data, or if one of its imports cannot be resolved). The exception message will provide details to explain /// why the library-load failed.</throws> public static HarmonyLibrary CreateFromBytes(byte[] rawDll, uint offset, uint length, string name = null, HarmonyLoadFlags loadFlags = 0, IEnumerable <HarmonyLibrary> otherLibraries = null) { LibraryLoader libraryLoader = new LibraryLoader(loadFlags, otherLibraries); HarmonyLibrary library = libraryLoader.CreateLibrary(rawDll, offset, length, name); return(library); }
public void GameTest() { Decks playingDecks = new Decks(); playingDecks.FillCards(); byte[] gameCards = new byte[416]; gameCards = playingDecks.Cards; byte bjFlag; int testResult; LibraryLoader libraryLoader = new LibraryLoader("../../../../BotsLibrary/BotsLibrary.dll"); Assembly asm = libraryLoader.LoadLibrary(); PluginHelper pluginHelper = new PluginHelper(asm); // Dealer has blackjack and player in both hands has blackjack too gameCards[0] = 10; gameCards[1] = 1; gameCards[2] = 1; gameCards[3] = 10; gameCards[4] = 10; gameCards[5] = 1; bjFlag = 3; testResult = 32; SomeGameTest(pluginHelper, playingDecks, gameCards, testResult, bjFlag); gameCards[0] = 10; gameCards[1] = 10; gameCards[2] = 10; gameCards[3] = 1; bjFlag = 0; testResult = -16; // Dealer has blackjack, player's score is 20. SomeGameTest(pluginHelper, playingDecks, gameCards, testResult, bjFlag); gameCards[0] = 10; gameCards[1] = 10; gameCards[2] = 10; gameCards[3] = 7; bjFlag = 0; testResult = 32; // Dealer has 17, player's score is 20. SomeGameTest(pluginHelper, playingDecks, gameCards, testResult, bjFlag); gameCards[0] = 10; gameCards[1] = 10; gameCards[2] = 5; gameCards[3] = 7; bjFlag = 0; testResult = 8; // Player surrendered SomeGameTest(pluginHelper, playingDecks, gameCards, testResult, bjFlag); gameCards[0] = 9; gameCards[1] = 8; gameCards[2] = 8; gameCards[3] = 9; gameCards[4] = 10; gameCards[5] = 6; gameCards[6] = 10; bjFlag = 0; testResult = 64; // Player won with both hands SomeGameTest(pluginHelper, playingDecks, gameCards, testResult, bjFlag); // Now we test two games successively playingDecks.FillCards(); gameCards = playingDecks.Cards; gameCards[0] = 10; gameCards[1] = 10; gameCards[2] = 5; gameCards[3] = 7; bjFlag = 0; testResult = 8; // Player surrendered uint initialMoney = 1600; BlackjackGame testGame = new BlackjackGame(playingDecks, initialMoney); object[] parameters = new object[] { testGame.PlayingDealer.DealerCards[0], (uint)testGame.InitialMoney, testGame.PlayingCards, (uint)16 }; pluginHelper.CreatePlayer(parameters, 1); testGame.Player = pluginHelper.players[1]; Assert.AreEqual(testGame.Game(), testResult); for (int i = 0; i < 416; i++) { Assert.AreEqual(testGame.PlayingCards.Cards[i], gameCards[i]); } // Second game gameCards[0] = 9; gameCards[1] = 8; gameCards[2] = 8; gameCards[3] = 9; gameCards[4] = 10; gameCards[5] = 6; gameCards[6] = 10; bjFlag = 0; testResult = 64; // Player won with both hands Assert.AreEqual(testGame.Game(), testResult); for (int i = 0; i < 416; i++) { Assert.AreEqual(testGame.PlayingCards.Cards[i], gameCards[i]); } }
public void Find_InParentDirectory_HasValidValues() { var sut = new LibraryLoader(new TrackConfigurationSearcher(), new TrackParser(new IniFormatParser())); var library = sut.LoadLibrary(TestLibraryPath); Assert.Equal(2, library.Items.Count()); Assert.All(library.Items, i => Assert.Equal("AC/DC", i.Song.Author)); }
/// <summary>Gets the reference to the Matrix Function library with respect to the configuration file. /// </summary> /// <returns>The reference to the Matrix Function library with respect to the configuration file.</returns> public static Basics.MatrixSpecialFunction.ILibrary CreateFromConfigurationFile() { var libraryLoader = new LibraryLoader <Basics.MatrixSpecialFunction.ILibrary>("MatrixFunction"); if (libraryLoader.Value != null) { return(libraryLoader.Value); } return(null); }
public void LoadLibrary_UseAddFunction() { var library = LibraryLoader.LoadLibrary("Soltys.VirtualMachine.Test"); Assert.Contains("add", library.Functions); var result = library.Functions["add"].Execute(6, 7); Assert.Equal(13, (int)result); }
/// <summary>Gets the reference to the FFT library with respect to the configuration file. /// </summary> /// <returns>The reference to the FFT library with respect to the configuration file, perhaps <c>null</c>.</returns> public static Basics.FFT.ILibrary CreateFromConfigurationFile() { var libraryLoader = new LibraryLoader <Basics.FFT.ILibrary>("FFT"); if (libraryLoader.Value != null) { return(libraryLoader.Value); } return(null); }
/// <summary>Gets the reference to the 'Special functions' library with respect to the configuration file. /// </summary> /// <returns>The reference to the 'Special functions' library with respect to the configuration file.</returns> internal static MathLibrary.Basics.SpecialFunction.ILibrary CreateFromConfigurationFile() { var libraryLoader = new LibraryLoader <MathLibrary.Basics.SpecialFunction.ILibrary>("SpecialFunctions"); if (libraryLoader.Value != null) { return(libraryLoader.Value); } return(null); }
public void testCreatureDeserialization() { LibraryLoader.loadMoveLibrary(); string creatureJSONString = "{\"creatureId\":1,\n\"creatureName\":\"\",\n\"baseStats\":[10,10,10,10],\n\"abilityId\":1,\n\"moves\":[\"Strike\",\"Slam\"],\n\"focalPoints\":[\n{\n\"description\":\"Small boost to strength\",\n\"statMods\":{\n\"STR\":[5,1]\n}\n},\n{\n\"description\":\"Small boost to armor\",\n\"statMods\":{\n\"ARM\":[5, 1]\n}\n},\n{\n\"description\":\"Additional armor scaling\",\n\"statMods\":{\n\"ARM\":[0, 1.1]\n}\n},\n{\n\"description\":\"Small boost to speed\",\n\"statMods\":{\n\"SPD\":[5, 1]\n}\n}\n],\n\"baseForm\":{\n\"creatureTypes\":[\"Vital\"],\n\"abilityId\":1,\n\"revealAction\":null\n},\n\"availableForms\":[\n{\n\"creatureTypes\":[\"Flame\"],\n\"statMods\":{\n\"STR\":[5, 1],\n\"ARM\":[0, 1],\n\"SPD\":[0, 1]\n},\n\"moveId\":null,\n\"abilityId\":1,\n\"revealAction\":null\n}\n]\n}"; JSONObject creatureJSON = JSONObject.Create(creatureJSONString); Creature actual = Creature.fromJSONObject(creatureJSON); HashSet <Move> expectedMoves = new HashSet <Move>(); expectedMoves.Add(MoveLibrary.get("Strike")); expectedMoves.Add(MoveLibrary.get("Slam")); StatModifier sm1 = new StatModifier(5, 1); StatModifier sm2 = new StatModifier(0, 1.1); StatModifier sm3 = new StatModifier(0, 1); FocusPoint fp1 = new FocusPoint(null, null, makeListOfStatMod(StatName.STR, sm1), "Small boost to strength"); FocusPoint fp2 = new FocusPoint(null, null, makeListOfStatMod(StatName.ARM, sm1), "Small boost to armor"); FocusPoint fp3 = new FocusPoint(null, null, makeListOfStatMod(StatName.ARM, sm2), "Additional armor scaling"); FocusPoint fp4 = new FocusPoint(null, null, makeListOfStatMod(StatName.SPD, sm1), "Small boost to speed"); FocalPoints expectedFocalPoints = new FocalPoints(fp1, fp2, fp3, fp4); CreatureStats expectedBaseStats = new CreatureStats(10, 10, 10, 10); Ability expectedAbility = null; HashSet <CreatureType> expectedTypesBase = new HashSet <CreatureType>(); expectedTypesBase.Add(CreatureType.VITAL); CreatureForm expectedBaseForm = new CreatureForm(expectedTypesBase, null, null); HashSet <CreatureType> expectedTypesForm = new HashSet <CreatureType>(); expectedTypesForm.Add(CreatureType.FLAME); List <Pair <StatName, StatModifier> > expectedFormMods = new List <Pair <StatName, StatModifier> >(); expectedFormMods.Add(new Pair <StatName, StatModifier>(StatName.STR, sm1)); expectedFormMods.Add(new Pair <StatName, StatModifier>(StatName.ARM, sm3)); expectedFormMods.Add(new Pair <StatName, StatModifier>(StatName.SPD, sm3)); CreatureForm expectedAltForm = new CreatureForm(expectedTypesForm, expectedFormMods, null, null, null); //"availableForms\":[\n{\n\"creatureTypes\":[\"Flame\"],\n\"statMods\":{\n\"STR\":[5, 1],\n\"ARM\":[0, 1],\n\"SPD\":[0, 1]\n},\n\"moveId\":null,\n\"abilityId\":1,\n\"revealAction\":null\n}\n] List <CreatureForm> expectedAvailableForms = new List <CreatureForm>(); expectedAvailableForms.Add(expectedAltForm); foreach (Pair <StatName, StatModifier> pair in expectedAltForm.statMods) { Debug.Log("Alt form mod: " + pair.ToString()); } Creature expected = new Creature(1, "", expectedMoves, expectedFocalPoints, expectedAbility, expectedBaseStats, expectedBaseForm, expectedAvailableForms); Assert.That(expected.Equals(actual)); }
/// <summary> /// Makes a new instance of <see cref="WindowsRuntime"/>, a specific /// implementation of pEngine for windows platform. /// </summary> public WindowsRuntime() : base() { // - Add Binaries folder to the search path LibraryLoader.Initialize(); // - Initialize GLFW GLFW.Glfw.Init(); // - Create the game window instance Surface = new GlfwWindow(new Vector2i(500, 500), Environment.Engine.Name); }
/// <summary> /// Invoke this library's PROCESS_DETACH handlers, if it has any. /// </summary> private unsafe void Detach() { LibraryLoader libraryLoader = new LibraryLoader(0, null); Image image = new Image((byte *)BaseAddress, AlignedImageSize); libraryLoader.ExecuteTlsFunctions(image, DllCallType.PROCESS_DETACH); if (Kind == HarmonyLibraryKind.Dll) { libraryLoader.ExecuteDllMain(image, DllCallType.PROCESS_DETACH); } }
public void PluginHelperTest() { LibraryLoader testLoader = new LibraryLoader("../../../../BotsLibrary/BotsLibrary.dll"); Assembly asm = testLoader.LoadLibrary(); PluginHelper testHelper = new PluginHelper(asm); // Invalid parameters in creating player string errorMessage = "Constructor on type 'BotsLibrary.CardsCounterStrategy' not found."; testHelper.CreatePlayer(null, 0); Assert.AreEqual(errorMessage, testHelper.LastExceptionMessage); }
public void AssembleInterfaceIsValid() { using (var ctx = CreateGlContext()) { ctx.MakeCurrent(); if (IsMac) { var lib = LibraryLoader.LoadLibrary("/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"); var glInterface = GRGlInterface.Create(name => { return(LibraryLoader.GetSymbol(lib, name)); }); Assert.NotNull(glInterface); Assert.True(glInterface.Validate()); LibraryLoader.FreeLibrary(lib); } else if (IsWindows) { var lib = LibraryLoader.LoadLibrary("opengl32.dll"); var glInterface = GRGlInterface.Create(name => { var ptr = LibraryLoader.GetSymbol(lib, name); if (ptr == IntPtr.Zero) { ptr = wglGetProcAddress(name); } return(ptr); }); Assert.NotNull(glInterface); Assert.True(glInterface.Validate()); LibraryLoader.FreeLibrary(lib); } else if (IsLinux) { var glInterface = GRGlInterface.Create(name => { return(glXGetProcAddress(name)); }); Assert.NotNull(glInterface); Assert.True(glInterface.Validate()); } else { // more platforms !!! throw new Exception("Some strange platform that is not Windows, macOS nor Linux..."); } } }
static void RunRepl() { WrenVM vm = new WrenVM(null, null); LibraryLoader.LoadLibraries(vm); WrenScript.LoadLibrary <ScriptTest>(vm); Console.WriteLine("-- wren v0.0.0"); string line = ""; for (; ;) { Console.Write("> "); line += Console.ReadLine() + "\n"; if (OpenBrackets(line) > 0) { continue; } // TODO: Handle failure. var result = new WrenVM.ResultRef(); var coroutine = vm.InterpretCoroutines("Prompt", "Prompt", line, result); // quick and dirty sim of unity's coroutines Stack <IEnumerator> stack = new Stack <IEnumerator>(); stack.Push(coroutine); while (stack.Count > 0) { if (!stack.Peek().MoveNext()) { stack.Pop(); } else { if (stack.Peek().Current is IEnumerator) { stack.Push(stack.Peek().Current as IEnumerator); } else { Console.WriteLine("yielded " + stack.Peek().Current); } } } line = ""; } }
private static IntPtr LoadLibrary(string libraryName) { var dependencies = LibraryDependenciesMap[libraryName]; dependencies.ForEach(x => GetOrLoadLibrary(x)); var version = LibraryVersionMap[libraryName]; var ptr = LibraryLoader.LoadNativeLibrary(RootPath, libraryName, version); if (ptr == IntPtr.Zero) { throw new DllNotFoundException($"Unable to load DLL '{libraryName}.{version}': The specified module could not be found."); } return(ptr); }
public MainWindow() { InitializeComponent(); IKernel kernel = new StandardKernel(); LibraryLoader.LoadAllBinDirectoryAssemblies(); if (File.Exists("TypeMappings.xml")) { kernel.Load("TypeMappings.xml"); } var plugins = kernel.GetAll <IPlugin>().ToList(); PluginsListView.ItemsSource = plugins; }