private static bool DMAsteroidAvailable() { if (_DMAst != null) { return(true); } if (DMAstRun) { return(false); } DMAstRun = true; try { Type DMAstType = AssemblyLoader.loadedAssemblies.SelectMany(a => a.assembly.GetExportedTypes()) .SingleOrDefault(t => t.FullName == DMAsteroidTypeName); if (DMAstType == null) { DMC_MBE.LogFormatted_DebugOnly("DMagic Asteroid Type Not Found"); return(false); } _DMAstType = DMAstType; MethodInfo DMastMethod = DMAstType.GetMethod("PartName"); if (DMastMethod == null) { DMC_MBE.LogFormatted_DebugOnly("DMagic Asteroid String Method Not Found"); return(false); } else { _DMAst = (DMAstSci)Delegate.CreateDelegate(typeof(DMAstSci), DMastMethod); DMC_MBE.LogFormatted("DMagic Asteroid Reflection Method Assigned"); } return(_DMAst != null); } catch (Exception e) { DMC_MBE.LogFormatted("Exception While Loading DMagic Asteroid Accessor: {0}", e); } return(false); }
private static bool DMAsteroidAvailable() { if (_DMAst != null) return true; if (DMAstRun) return false; DMAstRun = true; try { Type DMAstType = AssemblyLoader.loadedAssemblies.SelectMany(a => a.assembly.GetExportedTypes()) .SingleOrDefault(t => t.FullName == DMAsteroidTypeName); if (DMAstType == null) { DMC_MBE.LogFormatted_DebugOnly("DMagic Asteroid Type Not Found"); return false; } _DMAstType = DMAstType; MethodInfo DMastMethod = DMAstType.GetMethod("PartName"); if (DMastMethod == null) { DMC_MBE.LogFormatted_DebugOnly("DMagic Asteroid String Method Not Found"); return false; } else { _DMAst = (DMAstSci)Delegate.CreateDelegate(typeof(DMAstSci), DMastMethod); DMC_MBE.LogFormatted("DMagic Asteroid Reflection Method Assigned"); } return _DMAst != null; } catch (Exception e) { DMC_MBE.LogFormatted("Exception While Loading DMagic Asteroid Accessor: {0}", e); } return false; }