コード例 #1
0
ファイル: KACWrapper.cs プロジェクト: todi/KCT
                public AlarmStateChangedEventArgs(System.Object actualEvent, KACAPI kac)
                {
                    Type type = actualEvent.GetType();

                    this.alarm     = new KACAlarm(type.GetField("alarm").GetValue(actualEvent));
                    this.eventType = (KACAlarm.AlarmStateEventsEnum)type.GetField("eventType").GetValue(actualEvent);
                }
コード例 #2
0
ファイル: KACWrapper.cs プロジェクト: tinygrox/DeepFreeze
        /// <summary>
        /// This method will set up the KAC object and wrap all the methods/functions
        /// </summary>
        /// <returns></returns>
        public static Boolean InitKACWrapper()
        {
            //if (!_KACWrapped )
            //{
            //reset the internal objects
            _KACWrapped = false;
            actualKAC   = null;
            KAC         = null;
            LogFormatted_DebugOnly("Attempting to Grab KAC Types...");

            //find the base type
            KACType = getType("KerbalAlarmClock.KerbalAlarmClock");

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

            LogFormatted("KAC Version:{0}", KACType.Assembly.GetName().Version.ToString());
            if (KACType.Assembly.GetName().Version.CompareTo(new Version(3, 0, 0, 5)) < 0)
            {
                //No TimeEntry or alarmchoice options = need a newer version
                NeedUpgrade = true;
            }

            //now the Alarm Type
            KACAlarmType = getType("KerbalAlarmClock.KACAlarm");

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

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

            try
            {
                actualKAC = KACType.GetField("APIInstance", BindingFlags.Public | BindingFlags.Static).GetValue(null);
            }
            catch (Exception)
            {
                NeedUpgrade = true;
                LogFormatted("No APIInstance found - most likely you have KAC v2 installed");
                //throw;
            }
            if (actualKAC == 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");
            KAC = new KACAPI(actualKAC);
            //}
            _KACWrapped = true;
            return(true);
        }
コード例 #3
0
        /// <summary>
        /// This method will set up the KAC object and wrap all the methods/functions
        /// </summary>
        /// <param name="Force">This option will force the Init function to rebind everything</param>
        /// <returns></returns>
        public static Boolean InitKACWrapper()
        {
            //if (!_KSPARPWrapped )
            //{
            //reset the internal objects
            _KACWrapped = false;
            actualKAC   = null;
            KAC         = null;
            LogFormatted("Attempting to Grab KAC Types...");

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

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

            //now the resource Type
            KACAlarmType = AssemblyLoader.loadedAssemblies
                           .Select(a => a.assembly.GetExportedTypes())
                           .SelectMany(t => t)
                           .FirstOrDefault(t => t.FullName == "KerbalAlarmClock.KACAlarm");

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

            //now grab the running instance
            LogFormatted("Got Assembly Types, grabbing Instance");
            actualKAC = KACType.GetField("APIInstance", BindingFlags.Public | BindingFlags.Static).GetValue(null);

            if (actualKAC == null)
            {
                LogFormatted("Failed grabbing Instance");
                return(false);
            }

            //If we get this far we can set up the local object and its methods/functions
            LogFormatted("Got Instance, Creating Wrapper Objects");
            KAC = new KACAPI(actualKAC);
            //}
            _KACWrapped = true;
            return(true);
        }
コード例 #4
0
ファイル: KACWrapper.cs プロジェクト: stephengeorgewest/KOS-1
        /// <summary>
        /// This method will set up the KAC object and wrap all the methods/functions
        /// </summary>
        /// <param name="Force">This option will force the Init function to rebind everything</param>
        /// <returns></returns>
        public static Boolean InitKACWrapper()
        {
            // Prevent the init function from continuing to initialize if KerbalAlarmClock is not installed.
            if (hasAssembly == null)
            {
                LogFormatted("Attempting to Grab KAC Assembly...");
                hasAssembly = AssemblyLoader.loadedAssemblies.Any(a => a.dllName.Equals("KerbalAlarmClock"));
                if (hasAssembly.Value)
                {
                    LogFormatted("Found KAC Assembly!");
                }
                else
                {
                    LogFormatted("Did not find KAC Assembly.");
                }
            }
            if (!hasAssembly.Value)
            {
                _KACWrapped = false;
                return(_KACWrapped);
            }
            //if (!_KACWrapped )
            //{
            //reset the internal objects
            _KACWrapped = false;
            actualKAC   = null;
            KAC         = null;
            LogFormatted("Attempting to Grab KAC Types...");

            //find the base type
            KACType = GetType("KerbalAlarmClock.KerbalAlarmClock");

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

            LogFormatted("KAC Version:{0}", KACType.Assembly.GetName().Version.ToString());
            if (KACType.Assembly.GetName().Version.CompareTo(new System.Version(3, 0, 0, 5)) < 0)
            {
                //No TimeEntry or alarmchoice options = need a newer version
                NeedUpgrade = true;
            }

            //now the Alarm Type
            KACAlarmType = GetType("KerbalAlarmClock.KACAlarm");

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

            //now grab the running instance
            LogFormatted("Got Assembly Types, grabbing Instance");

            try {
                actualKAC = KACType.GetField("APIInstance", BindingFlags.Public | BindingFlags.Static).GetValue(null);
            } catch (Exception) {
                NeedUpgrade = true;
                LogFormatted("No APIInstance found - most likely you have KAC v2 installed");
                //throw;
            }
            if (actualKAC == null)
            {
                LogFormatted("Failed grabbing Instance");
                return(false);
            }

            //If we get this far we can set up the local object and its methods/functions
            LogFormatted("Got Instance, Creating Wrapper Objects");
            KAC = new KACAPI(actualKAC);
            //}
            _KACWrapped = true;
            return(true);
        }
コード例 #5
0
ファイル: WrapperKAC.cs プロジェクト: hashashin/CactEye
        /// <summary>
        /// This method will set up the KAC object and wrap all the methods/functions
        /// </summary>
        /// <param name="Force">This option will force the Init function to rebind everything</param>
        /// <returns></returns>
        public static Boolean InitKACWrapper()
        {
            //if (!_KSPARPWrapped )
            //{
            //reset the internal objects
            _KACWrapped = false;
            actualKAC = null;
            KAC = null;
            LogFormatted("Attempting to Grab KAC Types...");

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

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

            //now the resource Type
            KACAlarmType = AssemblyLoader.loadedAssemblies
                .Select(a => a.assembly.GetExportedTypes())
                .SelectMany(t => t)
                .FirstOrDefault(t => t.FullName == "KerbalAlarmClock.KACAlarm");

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

            //now grab the running instance
            LogFormatted("Got Assembly Types, grabbing Instance");
            actualKAC = KACType.GetField("APIInstance", BindingFlags.Public | BindingFlags.Static).GetValue(null);

            if (actualKAC == null)
            {
                LogFormatted("Failed grabbing Instance");
                return false;
            }

            //If we get this far we can set up the local object and its methods/functions
            LogFormatted("Got Instance, Creating Wrapper Objects");
            KAC = new KACAPI(actualKAC);
            //}
            _KACWrapped = true;
            return true;
        }
コード例 #6
0
        /// <summary>
        /// This method will set up the KAC object and wrap all the methods/functions
        /// </summary>
        /// <param name="Force">This option will force the Init function to rebind everything</param>
        /// <returns></returns>
        public static Boolean InitKACWrapper()
        {
            //if (!_KACWrapped )
            //{
            //reset the internal objects
            _KACWrapped = false;
            actualKAC   = null;
            KAC         = null;
            LogFormatted("Attempting to Grab KAC Types...");

            //find the base type
            // MOARdV: work around Contract Configurator - induced crash:
            //KACType = AssemblyLoader.loadedAssemblies
            //    .Select(a => a.assembly.GetExportedTypes())
            //    .SelectMany(t => t)
            //    .FirstOrDefault(t => t.FullName == "KerbalAlarmClock.KerbalAlarmClock");
            AssemblyLoader.loadedAssemblies.TypeOperation(t =>
            {
                if (t.FullName == "KerbalAlarmClock.KerbalAlarmClock")
                {
                    KACType = t;
                }
            });

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

            LogFormatted("KAC Version:{0}", KACType.Assembly.GetName().Version.ToString());
            if (KACType.Assembly.GetName().Version.CompareTo(new System.Version(3, 0, 0, 5)) < 0)
            {
                //No TimeEntry or alarmchoice options = need a newer version
                NeedUpgrade = true;
            }

            //now the Alarm Type
            // MOARdV: work around Contract Configurator - induced crash:
            //KACAlarmType = AssemblyLoader.loadedAssemblies
            //    .Select(a => a.assembly.GetExportedTypes())
            //    .SelectMany(t => t)
            //    .FirstOrDefault(t => t.FullName == "KerbalAlarmClock.KACAlarm");
            AssemblyLoader.loadedAssemblies.TypeOperation(t =>
            {
                if (t.FullName == "KerbalAlarmClock.KACAlarm")
                {
                    KACAlarmType = t;
                }
            });

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

            //now grab the running instance
            LogFormatted("Got Assembly Types, grabbing Instance");

            try {
                actualKAC = KACType.GetField("APIInstance", BindingFlags.Public | BindingFlags.Static).GetValue(null);
            } catch (Exception) {
                NeedUpgrade = true;
                LogFormatted("No APIInstance found - most likely you have KAC v2 installed");
                //throw;
            }
            if (actualKAC == null)
            {
                LogFormatted("Failed grabbing Instance");
                return(false);
            }

            //If we get this far we can set up the local object and its methods/functions
            LogFormatted("Got Instance, Creating Wrapper Objects");
            KAC = new KACAPI(actualKAC);
            //}
            _KACWrapped = true;
            return(true);
        }