Example #1
0
        public Module(IPlatformModuleLoader loader, IStartInfo startInfo)
        {
            SetupResourceMap();

            StartInfo = startInfo;
            Loader    = loader;

            Loader.Prepare();
        }
Example #2
0
        public Module(string modulePath, IPlatformModuleLoader loader, IStartInfo startInfo)
        {
            SetupResourceMap();

            StartInfo = startInfo;
            Loader    = loader;

            Loader.Prepare(modulePath);

            LoadResFile();
            LoadModuleHeader();
            SetupDatabase();
        }
Example #3
0
 public ProgramInfo(IStartInfo startInfo, Process process, AsyncStreamReadState[] streamArray)
 {
     StartInfo = startInfo;
     Process = process;
     StreamArray = streamArray;
 }
 /// <summary>
 /// Initialize this instance from the parameter instance.
 /// </summary>
 /// <param name="si">StartInfo instance used to initialise this instance.</param>
 public HandlerStartInfo(IStartInfo si)
 {
     RequestNumber = si.RequestNumber;
     RequestUser   = si.RequestUser;
 }
Example #5
0
        public IProgramInfo Spawn(IStartInfo startInfo)
        {
            var processStartInfo =
                new ProcessStartInfo
                    {
                        RedirectStandardError = true,
                        RedirectStandardInput = true,
                        RedirectStandardOutput = true,
                        ErrorDialog = false,
                        UseShellExecute = false,
                        FileName = startInfo.ProgramName,
                        WindowStyle = ProcessWindowStyle.Hidden,
                        CreateNoWindow = true,
                    };

            if (startInfo.Arguments != null) processStartInfo.Arguments = startInfo.Arguments;
            if (startInfo.WorkingDirectory != null) processStartInfo.WorkingDirectory = startInfo.WorkingDirectory;
            if (!File.Exists(startInfo.ProgramName))
                throw new ArgumentException(
                    "Could not find startInfo.ProgramName \""
                    + startInfo.ProgramName
                    + "\" to spawn."
                    );
            // ReSharper disable UseObjectOrCollectionInitializer
            // Object Collection Initializer can cause the creation of a temporary that doesn't get Dispose() called on it.
            var process = new Process();
            // ReSharper restore UseObjectOrCollectionInitializer

            process.StartInfo = processStartInfo;

            if (process.Start())
            {
                process.StandardInput.Write(startInfo.StdIn);
                process.StandardInput.Close();

                var streamArray =
                    new[]
                        {
                            new AsyncStreamReadState
                                {
                                    Stream = process.StandardOutput.BaseStream,
                                    Buffer = new byte[StreamReadBufferSize],
                                    AsyncResult = null,
                                    Writer = startInfo.StdOut,
                                },
                            new AsyncStreamReadState
                                {
                                    Stream = process.StandardError.BaseStream,
                                    Buffer = new byte[StreamReadBufferSize],
                                    AsyncResult = null,
                                    Writer = startInfo.StdErr,
                                }
                        };

                var pid = process.Id;
                var programInfo = new ProgramInfo(startInfo, process, streamArray);
                _trackedProcessDictionary[pid] = programInfo;

                foreach (var s in streamArray)
                    s.AsyncResult = s.Stream.BeginRead(s.Buffer, 0, s.Buffer.Length, ContinueRead, s);

                return programInfo;
            }
            throw new Exception("Could not start process: " + startInfo.ProgramName);
        }
Example #6
0
 public SerializableStartInfo(IStartInfo copyFrom)
 {
     this.Arguments = copyFrom.Arguments;
     this.FilePath  = copyFrom.FilePath;
 }