private static bool DMAnomalyAvailable() { if (_DMAnomaly != null) { return(true); } if (DMARun) { return(false); } DMARun = true; try { Type DMAType = AssemblyLoader.loadedAssemblies.SelectMany(a => a.assembly.GetExportedTypes()) .SingleOrDefault(t => t.FullName == DMAnomalyTypeName); if (DMAType == null) { DMC_MBE.LogFormatted_DebugOnly("DMagic Anomaly Type Not Found"); return(false); } _DMAType = DMAType; MethodInfo DManomalyMethod = DMAType.GetMethod("PartName"); if (DManomalyMethod == null) { DMC_MBE.LogFormatted_DebugOnly("DMagic Anomaly String Method Not Found"); return(false); } else { _DMAnomaly = (DMAnomalySci)Delegate.CreateDelegate(typeof(DMAnomalySci), DManomalyMethod); DMC_MBE.LogFormatted("DMagic Anomaly Reflection Method Assigned"); } return(_DMAnomaly != null); } catch (Exception e) { DMC_MBE.LogFormatted("Exception While Loading DMagic Anomaly Accessor: {0}", e); } return(false); }
private static bool DMAnomalyAvailable() { if (_DMAnomaly != null) return true; if (DMARun) return false; DMARun = true; try { Type DMAType = AssemblyLoader.loadedAssemblies.SelectMany(a => a.assembly.GetExportedTypes()) .SingleOrDefault(t => t.FullName == DMAnomalyTypeName); if (DMAType == null) { DMC_MBE.LogFormatted_DebugOnly("DMagic Anomaly Type Not Found"); return false; } _DMAType = DMAType; MethodInfo DManomalyMethod = DMAType.GetMethod("PartName"); if (DManomalyMethod == null) { DMC_MBE.LogFormatted_DebugOnly("DMagic Anomaly String Method Not Found"); return false; } else { _DMAnomaly = (DMAnomalySci)Delegate.CreateDelegate(typeof(DMAnomalySci), DManomalyMethod); DMC_MBE.LogFormatted("DMagic Anomaly Reflection Method Assigned"); } return _DMAnomaly != null; } catch (Exception e) { DMC_MBE.LogFormatted("Exception While Loading DMagic Anomaly Accessor: {0}", e); } return false; }