/// <summary>
        /// This method will set up the Remote Tech object and wrap all the methods/functions
        /// </summary>
        /// <returns>bool success of method call</returns>
        public static Boolean InitTRWrapper()
        {
            //reset the internal objects
            _RTWrapped  = false;
            actualRTAPI = null;
            LogFormatted_DebugOnly("Attempting to Grab Remote Tech Types...");

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

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

            LogFormatted("Remote Tech Version:{0}", RTAPIType.Assembly.GetName().Version.ToString());

            //now grab the running instance
            LogFormatted_DebugOnly("Got Assembly Types, grabbing Instances");
            try
            {
                actualRTAPI = RTAPIType.GetMember("HasLocalControl", BindingFlags.Public | BindingFlags.Static);
            }
            catch (Exception)
            {
                LogFormatted("No RemoteTech isInitialised found");
                //throw;
            }

            if (actualRTAPI == null)
            {
                LogFormatted("Failed grabbing RemoteTech 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");
            RTactualAPI = new RTAPI(actualRTAPI);

            _RTWrapped = true;
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method will set up the Remote Tech 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 InitTRWrapper()
        {
            //reset the internal objects
            _RTWrapped = false;
            actualRTAPI = null;
            LogFormatted_DebugOnly("Attempting to Grab Remote Tech Types...");

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

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

            LogFormatted("Remote Tech Version:{0}", RTAPIType.Assembly.GetName().Version.ToString());

            //now grab the running instance
            LogFormatted_DebugOnly("Got Assembly Types, grabbing Instances");
            try
            {
                actualRTAPI = RTAPIType.GetMember("HasLocalControl", BindingFlags.Public | BindingFlags.Static);
            }
            catch (Exception)
            {
                LogFormatted("No Remote Tech isInitialised found");
                //throw;
            }

            if (actualRTAPI == 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");
            RTactualAPI = new RTAPI(actualRTAPI);

            _RTWrapped = true;
            return true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// This method will set up the Remote Tech object and wrap all the methods/functions
        /// </summary>
        /// <returns></returns>
        public static Boolean InitTRWrapper()
        {
            //reset the internal objects
            _RTWrapped  = false;
            actualRTAPI = null;
            LogFormatted_DebugOnly("Attempting to Grab Remote Tech Types...");

            //find the base type
            RTAPIType = getType("RemoteTech.API.API");

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

            LogFormatted("Remote Tech Version:{0}", RTAPIType.Assembly.GetName().Version.ToString());

            //find the RTSettings type
            RTSettingsType = getType("RemoteTech.RTSettings");

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

            //find the Settings type
            SettingsType = getType("RemoteTech.Settings");

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

            //now the RTAntenna Type
            actualRTAntennaType = getType("RemoteTech.Modules.ModuleRTAntenna");

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

            //now grab the running instance
            LogFormatted_DebugOnly("Got Assembly Types, grabbing Instances");
            try
            {
                actualRTAPI = RTAPIType.GetMember("HasLocalControl", BindingFlags.Public | BindingFlags.Static);
            }
            catch (Exception ex)
            {
                LogFormatted("No Remote Tech isInitialised found");
                LogFormatted(ex.Message);
                //throw;
            }

            try
            {
                actualRTsettings = RTSettingsType.GetField("_instance", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
            }
            catch (Exception ex)
            {
                LogFormatted("No Remote Tech RTSettings Instance found");
                LogFormatted(ex.Message);
                //throw;
            }

            if (actualRTAPI == null || actualRTsettings == 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");
            RTactualAPI = new RTAPI(actualRTAPI);

            _RTWrapped = true;
            return(true);
        }