Пример #1
0
        /// <summary>
        /// This method will set up the USI LS object and wrap all the methods/functions
        /// </summary>
        /// <returns></returns>
        public static Boolean InitUSIWrapper()
        {
            //reset the internal objects
            _USIWrapped = false;
            actualUSI   = null;
            LogFormatted_DebugOnly("Attempting to Grab USI LS Types...");

            //find the base type
            USIType = getType("LifeSupport.LifeSupportScenario");

            if (USIType == null)
            {
                return(false);
            }

            LogFormatted("USI LS Version:{0}", USIType.Assembly.GetName().Version.ToString());

            //find the LifeSupportManager class type
            USILifeSupportMgrType = getType("LifeSupport.LifeSupportManager");

            if (USILifeSupportMgrType == null)
            {
                return(false);
            }


            //now grab the running instance
            LogFormatted_DebugOnly("Got Assembly Types, grabbing Instances");

            try
            {
                actualUSI = USILifeSupportMgrType.GetField("instance", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
            }
            catch (Exception)
            {
                LogFormatted("No USI LS LifeSupportManager Instance found");
                //throw;
            }
            //if (actualUSI == null || actualUSIUntrackKerbal == null)
            if (actualUSI == 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");
            USIActualAPI = new USIAPI(actualUSI);
            //USIIsKerbalTracked = new USIIsKerbalTrackedAPI(actualUSIIsKerbalTracked);

            _USIWrapped = true;
            return(true);
        }
Пример #2
0
        /// <summary>
        /// This method will set up the USI LS object and wrap all the methods/functions
        /// </summary>
        /// <returns></returns>
        public static Boolean InitUSIWrapper()
        {
            //reset the internal objects
            _USIWrapped = false;
            actualUSI = null;
            LogFormatted_DebugOnly("Attempting to Grab USI LS Types...");

            //find the base type
            USIType = AssemblyLoader.loadedAssemblies
                .Select(a => a.assembly.GetExportedTypes())
                .SelectMany(t => t)
                .FirstOrDefault(t => t.FullName == "LifeSupport.LifeSupportScenario");

            if (USIType == null)
            {
                return false;
            }

            LogFormatted("USI LS Version:{0}", USIType.Assembly.GetName().Version.ToString());

            //find the LifeSupportManager class type
            USILifeSupportMgrType = AssemblyLoader.loadedAssemblies
                .Select(a => a.assembly.GetExportedTypes())
                .SelectMany(t => t)
                .FirstOrDefault(t => t.FullName == "LifeSupport.LifeSupportManager");

            if (USILifeSupportMgrType == null)
            {
                return false;
            }

            //now grab the running instance
            LogFormatted_DebugOnly("Got Assembly Types, grabbing Instances");

            try
            {
                actualUSI = USILifeSupportMgrType.GetField("instance", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
            }
            catch (Exception)
            {
                LogFormatted("No USI LS LifeSupportManager Instance found");
                //throw;
            }
            //if (actualUSI == null || actualUSIUntrackKerbal == null)
            if (actualUSI == 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");
            USIActualAPI = new USIAPI(actualUSI);
            //USIIsKerbalTracked = new USIIsKerbalTrackedAPI(actualUSIIsKerbalTracked);

            _USIWrapped = true;
            return true;
        }