Example #1
0
        private static void Register(IEmulatorServiceProvider serviceProvider)
        {
            // Register external apis
            var apis = Assembly
                       .Load("BizHawk.Client.ApiHawk")
                       .GetTypes()
                       .Where(t => typeof(IExternalApi).IsAssignableFrom(t))
                       .Where(t => t.IsSealed)
                       .Where(t => ServiceInjector.IsAvailable(serviceProvider, t))
                       .ToList();

            apis.AddRange(
                Assembly
                .GetAssembly(typeof(ApiContainer))
                .GetTypes()
                .Where(t => typeof(IExternalApi).IsAssignableFrom(t))
                .Where(t => t.IsSealed)
                .Where(t => ServiceInjector.IsAvailable(serviceProvider, t)));

            foreach (var api in apis)
            {
                var instance = (IExternalApi)Activator.CreateInstance(api);
                ServiceInjector.UpdateServices(serviceProvider, instance);
                Libraries.Add(api, instance);
            }
            container             = new ApiContainer(Libraries);
            GlobalWin.ApiProvider = new BasicApiProvider(container);
        }
 public void Restart(
     IEmulatorServiceProvider newServiceProvider,
     Config config,
     IEmulator emulator,
     IGameInfo game)
 {
     _apiContainer = ApiManager.RestartLua(newServiceProvider, LogToLuaConsole, _mainForm, _displayManager, _inputManager, _mainForm.MovieSession, _mainForm.Tools, config, emulator, game);
     foreach (var lib in Libraries.Values)
     {
         lib.APIs = _apiContainer;
         ServiceInjector.UpdateServices(newServiceProvider, lib);
     }
 }
Example #3
0
 private static IExternalApiProvider Register(IEmulatorServiceProvider serviceProvider)
 {
     foreach (var api in Assembly.GetAssembly(typeof(ApiSubsetContainer)).GetTypes()
              .Concat(Assembly.GetAssembly(typeof(ApiContainer)).GetTypes())
              .Where(t => typeof(IExternalApi).IsAssignableFrom(t) && t.IsSealed && ServiceInjector.IsAvailable(serviceProvider, t)))
     {
         var instance = (IExternalApi)Activator.CreateInstance(api);
         ServiceInjector.UpdateServices(serviceProvider, instance);
         Libraries.Add(api, instance);
     }
     _container = new ApiContainer(Libraries);
     return(new BasicApiProvider(_container));
 }
Example #4
0
            static ApiContainer InitApiHawkContainerInstance(IEmulatorServiceProvider sp, Action <string> logCallback)
            {
                var ctorParamTypes = new[] { typeof(Action <string>) };
                var ctorParams     = new object[] { logCallback };
                var libDict        = new Dictionary <Type, IExternalApi>();

                foreach (var api in Assembly.GetAssembly(typeof(EmuApi)).GetTypes()
                         .Concat(Assembly.GetAssembly(typeof(ToolApi)).GetTypes())
                         .Where(t => t.IsSealed && typeof(IExternalApi).IsAssignableFrom(t) && ServiceInjector.IsAvailable(sp, t)))
                {
                    var ctorWithParams = api.GetConstructor(ctorParamTypes);
                    var instance       = (IExternalApi)(ctorWithParams == null ? Activator.CreateInstance(api) : ctorWithParams.Invoke(ctorParams));
                    ServiceInjector.UpdateServices(sp, instance);
                    libDict.Add(api, instance);
                }
                return(ApiHawkContainerInstance = new ApiContainer(libDict));
            }
 public ConsoleLuaLibrary(IPlatformLuaLibEnv luaLibsImpl, ApiContainer apiContainer, Action <string> logOutputCallback)
     : base(luaLibsImpl, apiContainer, logOutputCallback)
 {
 }