Exemple #1
0
        public static DriverConfiguration Initialise(params string[] assemblyNames)
        {
            foreach (var asmName in assemblyNames)
            {
                AppDomain.CurrentDomain.Load(asmName);
            }

            IMonitorDriver  monitorDriver  = null;
            IWindowDriver   windowDriver   = null;
            IImageDriver    imageDriver    = null;
            IFontDriver     fontDriver     = null;
            IGraphicsDriver graphicsDriver = null;
            IAudioDriver    audioDriver    = null;

            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                var jwdriver = assembly.GetCustomAttribute <JankWorksDriver>();

                if (jwdriver != null)
                {
                    var driverInstance = Activator.CreateInstance(jwdriver.DriverType);

                    SetDriverApi(ref monitorDriver, driverInstance);
                    SetDriverApi(ref windowDriver, driverInstance);
                    SetDriverApi(ref imageDriver, driverInstance);
                    SetDriverApi(ref fontDriver, driverInstance);
                    SetDriverApi(ref graphicsDriver, driverInstance);
                    SetDriverApi(ref audioDriver, driverInstance);
                }
            }

            var config = new DriverConfiguration
                         (
                monitorDriver,
                windowDriver,
                imageDriver,
                fontDriver,
                graphicsDriver,
                audioDriver
                         );

            DriverConfiguration.Drivers = config;
            return(config);

            void SetDriverApi <T>(ref T api, object driver)
            {
                if (api == null && driver is T driverApi)
                {
                    api = driverApi;
                }
            }
        }
Exemple #2
0
 public DriverConfiguration
 (
     IMonitorDriver monitorDriver   = null,
     IWindowDriver windowDriver     = null,
     IImageDriver imageDriver       = null,
     IFontDriver fontDriver         = null,
     IGraphicsDriver graphicsDriver = null,
     IAudioDriver audioDriver       = null
 )
 {
     this.monitorApi  = monitorDriver ?? DriverUnitialisedException.driver;
     this.windowApi   = windowDriver ?? DriverUnitialisedException.driver;
     this.imageApi    = imageDriver ?? DriverUnitialisedException.driver;
     this.fontApi     = fontDriver ?? DriverUnitialisedException.driver;
     this.graphicsApi = graphicsDriver ?? DriverUnitialisedException.driver;
     this.audioApi    = audioDriver ?? DriverUnitialisedException.driver;
 }
Exemple #3
0
 public ImageController(IImageDriver image) =>
 this.image = image;