public void StubContextIsUsedWhenRuntimeIsNotInitialized()
        {
            Type remoteCodeType = typeof(RemoteCode);

            AppDomainSetup appDomainSetup = new AppDomainSetup();

            appDomainSetup.ApplicationBase = Path.GetDirectoryName(AssemblyUtils.GetFriendlyAssemblyLocation(remoteCodeType.Assembly));

            AppDomain appDomain = AppDomain.CreateDomain("Test", null, appDomainSetup);

            try
            {
                RemoteCode remoteCode = (RemoteCode)appDomain.CreateInstanceAndUnwrap(remoteCodeType.Assembly.FullName, remoteCodeType.FullName);

                string output = remoteCode.Run();

                Assert.AreEqual("Test Section\n"
                                + "Foo\n",
                                output);
            }
            finally
            {
                AppDomain.Unload(appDomain);
            }
        }
Exemple #2
0
        public ActionResult Post(string remoteName, string commandName)
        {
            DAL dal = new DAL();

            try
            {
                Remote remote = dal.GetRemote(remoteName);

                if (remote == null)
                {
                    return(StatusCode(404, $"Remote {remoteName} not found"));
                }

                RemoteCode code = remote.Codes.FirstOrDefault(code => code.Name == commandName);

                if (code == null)
                {
                    return(StatusCode(404, $"Command {commandName} not found"));
                }

                dal.SendRemoteCode(code);

                return(Ok());
            }
            catch (NotSupportedException e)
            {
                return(StatusCode(501, e.Message));
            }
        }
        public void Post([FromBody] string remoteName, string commandName)
        {
            LircSharpAPI.DAL.DAL dal  = new DAL.DAL();
            RemoteCode           code = new RemoteCode();

            code.RemoteName = remoteName;
            code.Name       = commandName;

            dal.SendRemoteCode(code);
        }
Exemple #4
0
        public void SendRemoteCode(RemoteCode code)
        {
            /* Build process info to call LIRC */
            ProcessStartInfo procInfo = new ProcessStartInfo();

            procInfo.FileName               = "irsend";
            procInfo.UseShellExecute        = false;
            procInfo.RedirectStandardOutput = true;

            /* Ask LIRC for a list of remotes */
            procInfo.Arguments = "SEND_ONCE " + code.RemoteName + " " + code.Name;
            Process proc = Process.Start(procInfo);
        }
Exemple #5
0
        static void Main(string[] args)
        {
            var appID = "00000000";

            var netseal = new Broker();

            netseal.Initialize(appID);

            Remote               = new RemoteCode(appID, netseal.UserName);
            Remote.OnConnect    += Remote_OnConnect;
            Remote.OnDisconnect += Remote_OnDisconnect;
            Remote.Init("127.0.0.1", 12345);
            Application.Run();
        }
Exemple #6
0
        public List <RemoteCode> GetRemoteCodes(Remote remote)
        {
            List <RemoteCode> remoteCodeList = new List <RemoteCode>();

            /* Build process info to call LIRC */
            ProcessStartInfo procInfo = new ProcessStartInfo();

            procInfo.FileName               = "irsend";
            procInfo.UseShellExecute        = false;
            procInfo.RedirectStandardOutput = true;

            /* Ask LIRC for a list of remotes */
            procInfo.Arguments = "list " + remote.Name + " \"\"";
            try
            {
                Process proc   = Process.Start(procInfo);
                string  strOut = proc.StandardOutput.ReadToEnd();
                proc.WaitForExit();

                /* Extract the remote names from the LIRC return*/
                using (StringReader reader = new StringReader(strOut))
                {
                    string line = string.Empty;
                    do
                    {
                        line = reader.ReadLine();
                        if (!string.IsNullOrWhiteSpace(line))
                        {
                            RemoteCode code = new RemoteCode();
                            code.Name       = line.Split(' ')[1];
                            code.Command    = line.Split(' ')[0];
                            code.RemoteName = remote.Name;
                            remoteCodeList.Add(code);
                        }
                    } while (line != null);
                }
            }
            catch (Exception)
            {
                throw new NotSupportedException("LIRQ interface cannot be found");
            }

            return(remoteCodeList);
        }
Exemple #7
0
        public void SendRemoteCode(RemoteCode code)
        {
            /* Build process info to call LIRC */
            ProcessStartInfo procInfo = new ProcessStartInfo();

            procInfo.FileName               = "irsend";
            procInfo.UseShellExecute        = false;
            procInfo.RedirectStandardOutput = true;

            /* Ask LIRC for a list of remotes */
            procInfo.Arguments = "SEND_ONCE " + code.RemoteName + " " + code.Name;

            Process proc   = Process.Start(procInfo);
            string  strOut = proc.StandardOutput.ReadToEnd();

            proc.WaitForExit();

            if (strOut.Contains("hardware does not support"))
            {
                throw new NotSupportedException(strOut);
            }
        }
Exemple #8
0
        public List <RemoteCode> GetRemoteCodes(Remote remote)
        {
            List <RemoteCode> remoteCodeList = new List <RemoteCode>();

            /* Build process info to call LIRC */
            ProcessStartInfo procInfo = new ProcessStartInfo();

            procInfo.FileName               = "irsend";
            procInfo.UseShellExecute        = false;
            procInfo.RedirectStandardOutput = true;

            /* Ask LIRC for a list of remotes */
            procInfo.Arguments = "list " + remote.Name + " \"\"";
            Process proc   = Process.Start(procInfo);
            string  strOut = proc.StandardOutput.ReadToEnd();

            proc.WaitForExit();

            /* Extract the remote names from the LIRC return*/
            using (StringReader reader = new StringReader(strOut))
            {
                string     line = string.Empty;
                RemoteCode code;
                do
                {
                    line = reader.ReadLine();
                    if (line != null && line.StartsWith("irsend: "))
                    {
                        code            = new RemoteCode();
                        code.Name       = line.Split(' ')[2];
                        code.Command    = line.Split(' ')[1];
                        code.RemoteName = remote.Name;
                    }
                } while (line != null);
            }

            return(remoteCodeList);
        }