Exemplo n.º 1
0
        protected string ResolveFileText(ref string filePath)
        {
            if (DoPropertyResolve)
            {
                string tmpFileName = Path.ChangeExtension(ChoPath.GetTempFileName(), Path.GetExtension(filePath));
                File.WriteAllText(tmpFileName, File.ReadAllText(filePath).ExpandProperties());
                filePath = tmpFileName;
                ChoTrace.DebugFormat("{0}: Temp file created at '{1}'", Name, tmpFileName);
                return(tmpFileName);
            }

            return(null);
        }
Exemplo n.º 2
0
        protected override object Execute(object value, out bool isHandled)
        {
            isHandled = false;
            if (Script.IsNullOrWhiteSpace())
            {
                return(value);
            }

            string script           = ResolveText(Script);
            string arguments        = !Arguments.IsNullOrWhiteSpace() ? "{0} {1}".FormatString(value.ToNString(), ResolveText(Arguments)) : value.ToNString();
            string workingDirectory = WorkingDirectory.IsNullOrWhiteSpace() ? ChoApplication.ApplicationBaseDirectory : ResolveText(WorkingDirectory);

            //Create temp script file
            _tmpFileName = Path.ChangeExtension(ChoPath.GetTempFileName(), ChoReservedFileExt.JS);
            File.WriteAllText(_tmpFileName, script);
            ChoTrace.DebugFormat("{0}: Temp file created at '{1}'", Name, _tmpFileName);

            using (ChoProcess p = new ChoProcess("cscript.exe", "{0} {1} //Nologo".FormatString(_tmpFileName, arguments)))
            {
                p.WorkingDirectory = workingDirectory;

                return(p.Execute().StdOut);
            }
        }