internal TACLSAPI(Object a) { Instance = this; actualTACLSAPI = a; getEnabledMethod = TACLSType.GetMethod("get_Enabled", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); BaseElectricityConsumptionRateMethod = TACLSType.GetMethod("get_BaseElectricityConsumptionRate", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); ElectricityConsumptionRateMethod = TACLSType.GetMethod("get_ElectricityConsumptionRate", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); }
/// <summary> /// This method will set up the TAC LS object and wrap all the methods/functions /// </summary> /// <returns></returns> public static Boolean InitTACLSWrapper() { //reset the internal objects _TACLSWrapped = false; actualTACLS = null; LogFormatted_DebugOnly("Attempting to Grab TAC LS Types..."); //find the base type TACLSType = getType("Tac.TacLifeSupport"); if (TACLSType == null) { return(false); } LogFormatted("TAC LS Version:{0}", TACLSType.Assembly.GetName().Version.ToString()); TACLSGenericConverterType = getType("Tac.TacGenericConverter"); if (TACLSGenericConverterType == null) { return(false); } //now grab the running instance LogFormatted_DebugOnly("Got Assembly Types, grabbing Instances"); try { actualTACLS = TACLSType.GetField("Instance", BindingFlags.Public | BindingFlags.Static).GetValue(null); } catch (Exception) { LogFormatted("No TAC LS Instance found"); //throw; } if (actualTACLS == null) { LogFormatted("Failed grabbing Instance"); return(false); } //If we get this far we can set up the local object and its methods/functions LogFormatted_DebugOnly("Got Instance, Creating Wrapper Objects"); TACactualAPI = new TACLSAPI(actualTACLS); _TACLSWrapped = true; return(true); }