Пример #1
0
        protected bool _XProgram(XInput xinput, XOutput xoutput, XOutput xerror, XOutput xlog)
        {
            bool bRes = XPrograms.ContainsKey(xinput.XFirst);

            if (bRes)
            {
                XProgram xprogram = XPrograms[xinput.XFirst];
                bRes = xprogram.XMain(false, xprogram.XInput, xprogram.XOutput, xprogram.XError, xprogram.XLog);
            }
            else
            {
                string  childInputRead   = null;
                XOutput xchildInputWrite = null;
                bRes = XCreateOutput(out xchildInputWrite, out childInputRead);
                string childOutputWrite = null;
                XInput xchildOutputRead = null;
                bRes = XCreateInput(out xchildOutputRead, out childOutputWrite);
                if (bRes)
                {
                    string[] args     = new string[] { xinput.XFirst, XIN, childInputRead, XOUT, childOutputWrite };
                    XArgs    xargs    = new XArgs(args);
                    XProgram xprogram = null;
                    bRes = XStartProgram(xargs, out xprogram);
                    if (bRes)
                    {
                        XPrograms[xinput.XFirst] = xprogram;
                        bRes = xchildOutputRead.XRead();
                        if (bRes)
                        {
                            string childOutputRead    = xchildOutputRead.XRead(XOUT);
                            XInput xremoteChildOutput = null;
                            bRes = XCreateRemoteInput(childOutputRead, out xremoteChildOutput);
                            if (bRes)
                            {
                                string childErrorRead    = xchildOutputRead.XRead(XERR);
                                XInput xremoteChildError = null;
                                bRes = XCreateRemoteInput(childErrorRead, out xremoteChildError);
                                if (bRes)
                                {
                                    string childLogRead    = xchildOutputRead.XRead(XLOG);
                                    XInput xremoteChildLog = null;
                                    bRes = XCreateRemoteInput(childLogRead, out xremoteChildLog);
                                    if (bRes)
                                    {
                                        xprogram.XInput  = new XRemoteInput(xinput, xchildInputWrite);
                                        xprogram.XOutput = new XRemoteOutput(xoutput, xremoteChildOutput);
                                        xprogram.XError  = new XRemoteOutput(xerror, xremoteChildError);
                                        xprogram.XLog    = new XRemoteOutput(xlog, xremoteChildLog);
                                        bRes             = XMain(false, xprogram.XInput, xprogram.XOutput, xprogram.XError, xprogram.XLog);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(bRes);
        }
Пример #2
0
        public override bool XReadStrings(out List <string> strings)
        {
            bool bRes = XInput.XReadStrings(out strings);

            if (bRes)
            {
                bRes = XOutput.XWriteStrings(strings);
            }
            return(bRes);
        }
Пример #3
0
        protected bool XMain(bool main, XInput xinput, XOutput xoutput, XOutput xerror, XOutput xlog)
        {
            bool bRes = true;

            while (bRes)
            {
                bRes = xinput.XRead();
                if (bRes)
                {
                    if (main)
                    {
                        bRes = XIsProgram(xinput);
                        if (bRes)
                        {
                            bRes = _XProgram(xinput, xoutput, xerror, xlog);
                        }
                        else
                        {
                            bRes = XIsFunction(xinput);
                            if (bRes)
                            {
                                bRes = XFunction(xinput, xoutput, xerror, xlog);
                            }
                        }
                    }

                    if (bRes)
                    {
                        bRes = xoutput.XWrite();
                        if (bRes)
                        {
                            bRes = xerror.XWrite();
                            if (bRes)
                            {
                                bRes = xoutput.XWrite();
                            }
                        }
                    }
                }
            }
            return(bRes);
        }
Пример #4
0
 public XRemoteInput(XInput xinput, XOutput xoutput) : base()
 {
     XInput  = xinput;
     XOutput = xoutput;
 }
Пример #5
0
 public XRemoteOutput(XOutput xoutput, XInput xinput)
 {
 }
Пример #6
0
        public void XMain(XInput xargs)
        {
            bool bRes = xargs.XRead();

            if (bRes)
            {
                string input  = xargs.XRead(XIN);
                string output = xargs.XRead(XOUT);
                string error  = xargs.XRead(XERR);
                string log    = xargs.XRead(XLOG);

                XInput  xinput  = null;
                XOutput xoutput = null;
                XOutput xerror  = null;
                XOutput xlog    = null;

                if (input == null)
                {
                    xinput  = new XStdInput();
                    xoutput = new XStdOutput();
                    xerror  = new XStdOutput();
                    xlog    = new XStdOutput();
                }
                else
                {
                    bRes = XCreateRemoteInput(input, out xinput);
                    if (bRes)
                    {
                        if (output == null)
                        {
                            xoutput = new XStdOutput();
                            if (error == null)
                            {
                                xerror = new XStdOutput();
                            }
                            else
                            {
                                bRes = XCreateRemoteOutput(error, out xerror);
                            }

                            if (log == null)
                            {
                                xlog = new XStdOutput();
                            }
                            else
                            {
                                bRes = XCreateRemoteOutput(log, out xlog);
                            }
                        }
                        else
                        {
                            XOutput xparentOutput = null;
                            bRes = XCreateRemoteOutput(output, out xparentOutput);
                            if (bRes)
                            {
                                string newOutput = null;
                                bRes = XCreateOutput(out xoutput, out newOutput);
                                if (bRes)
                                {
                                    xparentOutput.XWrite(XOUT, newOutput);
                                }
                                if (bRes)
                                {
                                    string newError = null;
                                    bRes = XCreateOutput(out xerror, out newError);
                                    if (bRes)
                                    {
                                        xparentOutput.XWrite(XERR, newError);
                                    }
                                }

                                if (bRes)
                                {
                                    string newLog = null;
                                    bRes = XCreateOutput(out xlog, out newLog);
                                    if (bRes)
                                    {
                                        xparentOutput.XWrite(XLOG, newLog);
                                    }
                                }

                                if (bRes)
                                {
                                    bRes = xparentOutput.XWrite();
                                }
                            }
                        }
                    }
                }

                bRes = XMain(true, xinput, xoutput, xerror, xlog);
                bRes = XClose();
            }
        }
Пример #7
0
 protected abstract bool XCreateRemoteInput(string input, out XInput xinput);
Пример #8
0
 protected abstract bool XCreateInput(out XInput xintput, out string output);
Пример #9
0
 protected abstract bool XStartProgram(XInput xargs, out XProgram xprogram);
Пример #10
0
 protected abstract bool XFunction(XInput xinput, XOutput xouput, XOutput xerror, XOutput xlog);
Пример #11
0
 protected abstract bool XIsProgram(XInput xinput);
Пример #12
0
 protected abstract bool XIsFunction(XInput xinput);