private static AgateDriverInfo FindDriverInfo(List <AgateDriverInfo> driverList, int typeID) { AgateDriverInfo theInfo = null; if (driverList.Count == 0) { return(null); } // autoselect ID's are all zero if (typeID == 0) { return(driverList[0]); } foreach (AgateDriverInfo info in driverList) { if (info.DriverTypeID != typeID) { continue; } theInfo = info; } return(theInfo); }
private static AgateDriverInfo FindDriverInfo(List <AgateDriverInfo> driverList, string assemblyFullName) { AgateDriverInfo theInfo = null; foreach (AgateDriverInfo info in driverList) { if (info.AssemblyName != assemblyFullName) { continue; } theInfo = info; } return(theInfo); }
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { AgateDriverInfo info = null; info = info ?? FindDriverInfo(displayDrivers, args.Name); info = info ?? FindDriverInfo(audioDrivers, args.Name); info = info ?? FindDriverInfo(inputDrivers, args.Name); info = info ?? FindDriverInfo(desktopDrivers, args.Name); if (info == null) { return(null); } return(LoadAssemblyLoadFrom(info)); }
private static object CreateDriverInstance(AgateDriverInfo info) { Assembly ass = Assembly.Load(info.AssemblyName); Type driverType = ass.GetType(info.DriverTypeName, false); if (driverType == null) { throw new AgateException(string.Format( "Could not find the type {0} in the library {1}.", info.DriverTypeName, ass.FullName)); } return(Activator.CreateInstance(driverType)); }
internal static InputImpl CreateInputDriver(InputTypeID inputType) { if (inputDrivers.Count == 0) { throw new AgateException("No audio drivers registered."); } AgateDriverInfo info = FindDriverInfo(inputDrivers, (int)inputType); if (info == null) { throw new AgateException(string.Format("Could not find the driver {0}.", inputType)); } return((InputImpl)CreateDriverInstance(info)); }
internal static AudioImpl CreateAudioDriver(AudioTypeID audioType) { if (audioDrivers.Count == 0) { throw new AgateException("No audio drivers registered."); } AgateDriverInfo info = FindDriverInfo(audioDrivers, (int)audioType); if (info == null) { throw new AgateException(string.Format("Could not find the driver {0}.", audioType)); } return((AudioImpl)CreateDriverInstance(info)); }
internal static DisplayImpl CreateDisplayDriver(DisplayTypeID displayType) { if (displayDrivers.Count == 0) { throw new AgateException("No display drivers registered."); } AgateDriverInfo info = FindDriverInfo(displayDrivers, (int)displayType); if (info == null) { throw new AgateException(string.Format("Could not find the driver {0}.", displayType)); } return((DisplayImpl)CreateDriverInstance(info)); }
private static void RegisterNullDrivers() { Assembly thisAssembly = Assembly.GetExecutingAssembly(); AgateDriverInfo nullAudioInfo = new AgateDriverInfo(AudioTypeID.Silent, typeof(NullSoundImpl), "No audio", -100); nullAudioInfo.AssemblyFile = thisAssembly.CodeBase; nullAudioInfo.AssemblyName = thisAssembly.FullName; audioDrivers.Add(nullAudioInfo); AgateDriverInfo nullInputInfo = new AgateDriverInfo(InputTypeID.Silent, typeof(NullInputImpl), "No input", -100); nullInputInfo.AssemblyFile = thisAssembly.CodeBase; nullInputInfo.AssemblyName = thisAssembly.FullName; inputDrivers.Add(nullInputInfo); }
private static Assembly LoadAssemblyLoadFrom(AgateDriverInfo info) { Core.ReportError(ErrorLevel.Warning, string.Format("Assembly {0} was loaded in the LoadFrom context. Move it to the application directory to load in the Load context.", info.AssemblyName), null); return(Assembly.LoadFrom(info.AssemblyFile)); }