[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/System/Diagnostics EventLogTraceList
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/System/Diagnostics EventLogTraceListener.cs,NONE,1.1 ICollectData.cs,NONE,1.1 PerformanceCounterManager.cs,NONE,1.1 ProcessModule.cs,NONE,1.1 ProcessModuleCollection.cs,NONE,1.1 ProcessThread.cs,NONE,1.1 ProcessThreadCollection.cs,NONE,1.1 Process.cs,1.3,1.4 ProcessStartInfo.cs,1.1,1.2 |
Date: |
Fri, 11 Apr 2003 22:52:50 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System/Diagnostics
In directory subversions:/tmp/cvs-serv3036/System/Diagnostics
Modified Files:
Process.cs ProcessStartInfo.cs
Added Files:
EventLogTraceListener.cs ICollectData.cs
PerformanceCounterManager.cs ProcessModule.cs
ProcessModuleCollection.cs ProcessThread.cs
ProcessThreadCollection.cs
Log Message:
Implement the process start/management classes.
--- NEW FILE ---
/*
* EventLogTraceListener.cs - Implementation of the
* "System.Diagnostics.EventLogTraceListener" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Diagnostics
{
#if !ECMA_COMPAT
public class EventLogTraceListener : TraceListener
{
// Internal state.
private EventLog eventLog;
// Constructor.
public EventLogTraceListener() {}
public EventLogTraceListener(EventLog eventLog)
{
this.eventLog = eventLog;
}
public EventLogTraceListener(String source)
{
eventLog = new EventLog();
eventLog.Source = source;
}
// Get or set the event log to output trace messages to.
public EventLog EventLog
{
get
{
return eventLog;
}
set
{
eventLog = value;
}
}
// Get or set the name of the event log.
public override String Name
{
get
{
String name = base.Name;
if(name == null || name == String.Empty)
{
if(eventLog != null)
{
name = base.Name =
eventLog.Source;
}
}
return name;
}
set
{
base.Name = value;
}
}
// Close this trace listener.
public override void Close()
{
if(eventLog != null)
{
eventLog.Close();
}
}
// Dispose of this trace listener.
protected override void Dispose(bool disposing)
{
if(disposing)
{
Close();
}
}
// Write data to this trace listener's output stream.
public override void Write(String message)
{
if(eventLog != null)
{
eventLog.WriteEntry(message);
}
}
// Write data to this trace listener's output stream followed by
newline.
public override void WriteLine(String message)
{
Write(message);
}
}; // class EventLogTraceListener
#endif // !ECMA_COMPAT
}; // namespace System.Diagnostics
--- NEW FILE ---
/*
* ICollectData.cs - Implementation of the
* "System.Diagnostics.ICollectData" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Diagnostics
{
#if !ECMA_COMPAT
using System.Runtime.InteropServices;
[Guid("73386977-D6FD-11D2-BED5-00C04F79E3AE")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ICollectData
{
void CloseData();
void CollectData(int id, IntPtr valueName, IntPtr data,
int totalBytes, out IntPtr res);
}; // interface ICollectData
#endif // !ECMA_COMPAT
}; // namespace System.Diagnostics
--- NEW FILE ---
/*
* PerformanceCounterManager.cs - Implementation of the
* "System.Diagnostics.PerformanceCounterManager" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Diagnostics
{
#if !ECMA_COMPAT
public sealed class PerformanceCounterManager : ICollectData
{
// Constructor.
public PerformanceCounterManager() {}
// Implement the ICollectData interface.
void ICollectData.CloseData()
{
// Not used by this implementation.
}
void ICollectData.CollectData(int id, IntPtr valueName, IntPtr data,
int
totalBytes, out IntPtr res)
{
// Not used by this implementation.
res = IntPtr.Zero;
}
}; // class PerformanceCounterManager
#endif // !ECMA_COMPAT
}; // namespace System.Diagnostics
--- NEW FILE ---
/*
* ProcessModule.cs - Implementation of the
* "System.Diagnostics.ProcessModule" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Diagnostics
{
#if !ECMA_COMPAT
using System.ComponentModel;
// We don't support module information blocks, because they aren't
// portable to non-Windows operating systems. So this class returns
// dummy information.
public class ProcessModule : Component
{
// Internal state.
private String fileName;
private String moduleName;
// Constructor.
internal ProcessModule(String fileName, String moduleName)
{
this.fileName = fileName;
this.moduleName = moduleName;
}
// Module properties.
public IntPtr BaseAddress
{
get
{
return IntPtr.Zero;
}
}
public IntPtr EntryPointAddress
{
get
{
return IntPtr.Zero;
}
}
public String FileName
{
get
{
return fileName;
}
}
public FileVersionInfo FileVersionInfo
{
get
{
return
FileVersionInfo.GetVersionInfo(fileName);
}
}
public int ModuleMemorySize
{
get
{
return 0;
}
}
public String ModuleName
{
get
{
return moduleName;
}
}
// Convert this object into a string.
public override String ToString()
{
return ModuleName;
}
}; // class ProcessModule
#endif // !ECMA_COMPAT
}; // namespace System.Diagnostics
--- NEW FILE ---
/*
* ProcessModuleCollection.cs - Implementation of the
* "System.Diagnostics.ProcessModuleCollection" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Diagnostics
{
#if !ECMA_COMPAT
using System.Collections;
public class ProcessModuleCollection : ReadOnlyCollectionBase
{
// Constructor.
protected ProcessModuleCollection() {}
public ProcessModuleCollection(ProcessModule[] processModules)
{
InnerList.AddRange(processModules);
}
internal ProcessModuleCollection(ProcessModule module)
{
InnerList.Add(module);
}
// Get collection member.
public ProcessModule this[int index]
{
get
{
return
(ProcessModule)(InnerList[index]);
}
}
// Add an element to this collection.
internal void Add(ProcessModule value)
{
InnerList.Add(value);
}
// Determine if an item exists in this collection.
public bool Contains(ProcessModule value)
{
return InnerList.Contains(value);
}
// Copy the elements in this collection to an array.
public void CopyTo(ProcessModule[] array, int index)
{
InnerList.CopyTo(array, index);
}
// Get the index of a specific element in this collection.
public int IndexOf(ProcessModule value)
{
return InnerList.IndexOf(value);
}
}; // class ProcessModuleCollection
#endif // !ECMA_COMPAT
}; // namespace System.Diagnostics
--- NEW FILE ---
/*
* ProcessThread.cs - Implementation of the
* "System.Diagnostics.ProcessThread" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Diagnostics
{
#if !ECMA_COMPAT
using System.ComponentModel;
// We don't really support thread information in this implementation,
// because it isn't portable. Instead, we mirror the process information,
// making it look like there is a single-thread process running. This
// may be a bit weird if the current process is inspected and the program
// has created threads using "System.Threading.Thread". Therefore, use
// of this API is severely discouraged.
public class ProcessThread : Component
{
// Internal state.
private Process process;
// Constructor.
internal ProcessThread(Process process)
{
this.process = process;
}
// Thread properties.
public int BasePriority
{
get
{
return process.BasePriority;
}
}
public int CurrentPriority
{
get
{
// Current is always the same as base
in this version.
return process.BasePriority;
}
}
public int Id
{
get
{
return process.Id;
}
}
public int IdealProcessor
{
set
{
process.ProcessorAffinity = new
IntPtr(1 << value);
}
}
public bool PriorityBoostEnabled
{
get
{
return process.PriorityBoostEnabled;
}
set
{
process.PriorityBoostEnabled = value;
}
}
public ThreadPriorityLevel PriorityLevel
{
get
{
return ThreadPriorityLevel.Normal;
}
set
{
// Cannot change the priority level for
threads.
}
}
public TimeSpan PrivilegedProcessorTime
{
get
{
return process.PrivilegedProcessorTime;
}
}
public IntPtr ProcessorAffinity
{
set
{
process.ProcessorAffinity = value;
}
}
public IntPtr StartAddress
{
get
{
return IntPtr.Zero;
}
}
public DateTime StartTime
{
get
{
return process.StartTime;
}
}
public ThreadState ThreadState
{
get
{
// Assume that the thread is running,
because there
// is no portable way to find out what
it is doing.
return ThreadState.Running;
}
}
public TimeSpan TotalProcessorTime
{
get
{
return process.TotalProcessorTime;
}
}
public TimeSpan UserProcessorTime
{
get
{
return process.UserProcessorTime;
}
}
public ThreadWaitReason WaitReason
{
get
{
// Since the thread is supposedly
running (see above),
// there is no way that it can be in
the wait state.
throw new InvalidOperationException
(S._("Invalid_NotWaiting"));
}
}
// Reset the ideal processor setting.
public void ResetIdealProcessor()
{
process.ProcessorAffinity = new IntPtr(~0);
}
}; // class ProcessThread
#endif // !ECMA_COMPAT
}; // namespace System.Diagnostics
--- NEW FILE ---
/*
* ProcessThreadCollection.cs - Implementation of the
* "System.Diagnostics.ProcessThreadCollection" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Diagnostics
{
#if !ECMA_COMPAT
using System.Collections;
public class ProcessThreadCollection : ReadOnlyCollectionBase
{
// Constructor.
protected ProcessThreadCollection() {}
public ProcessThreadCollection(ProcessThread[] processModules)
{
InnerList.AddRange(processModules);
}
internal ProcessThreadCollection(ProcessThread module)
{
InnerList.Add(module);
}
// Get collection member.
public ProcessThread this[int index]
{
get
{
return
(ProcessThread)(InnerList[index]);
}
}
// Add an element to this collection.
public void Add(ProcessThread value)
{
InnerList.Add(value);
}
// Determine if an item exists in this collection.
public bool Contains(ProcessThread value)
{
return InnerList.Contains(value);
}
// Copy the elements in this collection to an array.
public void CopyTo(ProcessThread[] array, int index)
{
InnerList.CopyTo(array, index);
}
// Get the index of a specific element in this collection.
public int IndexOf(ProcessThread value)
{
return InnerList.IndexOf(value);
}
// Insert a thread into this collection.
public void Insert(int index, ProcessThread thread)
{
InnerList.Insert(index, thread);
}
// Remove a thread from this collection.
public void Remove(ProcessThread thread)
{
InnerList.Remove(thread);
}
}; // class ProcessThreadCollection
#endif // !ECMA_COMPAT
}; // namespace System.Diagnostics
Index: Process.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System/Diagnostics/Process.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Process.cs 14 Feb 2003 14:58:09 -0000 1.3
--- Process.cs 12 Apr 2003 02:52:47 -0000 1.4
***************
*** 1,8 ****
/*
! * Process.cs - Implementation of "System.Diagnostics.Process"
*
! * Copyright (C) 2002 Southern Storm Software, Pty Ltd.
! *
! * Contributed by Gopal.V
*
* This program is free software; you can redistribute it and/or modify
--- 1,6 ----
/*
[...1511 lines suppressed...]
! // Wait for a particular process to enter the idle state after startup.
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern private static bool WaitForInputIdle
! (IntPtr processHandle, int processID, int milliseconds);
!
! // Start a new process. Returns false if it could not be started.
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern private static bool StartProcess
! (String filename, String arguments, String[] argv,
! int flags, int windowStyle, String[] envVars,
! String verb, IntPtr errorDialogParent,
! out IntPtr processHandle, out int processID,
! out IntPtr stdinHandle, out IntPtr stdoutHandle,
! out IntPtr stderrHandle);
!
! }; // class Process
!
! #endif // !ECMA_COMPAT
!
! }; // namespace System.Diagnostics
Index: ProcessStartInfo.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System/Diagnostics/ProcessStartInfo.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ProcessStartInfo.cs 4 Jan 2003 16:44:45 -0000 1.1
--- ProcessStartInfo.cs 12 Apr 2003 02:52:47 -0000 1.2
***************
*** 1,9 ****
/*
! * ProcessStartInfo.cs - Implementation of
! *
"System.Diagnostics.ProcessStartInfo" class
*
! * Copyright (C) 2002 Southern Storm Software, Pty Ltd.
! *
! * contributed by Gopal.V
*
* This program is free software; you can redistribute it and/or modify
--- 1,7 ----
/*
! * ProcessStartInfo.cs - Implementation of the
! * "System.Diagnostics.ProcessStartInfo" class.
*
! * Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
***************
*** 22,230 ****
*/
- using System;
- using System.Collections;
- using System.Collections.Specialized;
-
namespace System.Diagnostics
{
- public sealed class ProcessStartInfo
- {
- private String filename=null;
- private String arguments="";
- private bool createNoWindow=false;
- private StringDictionary dict=null;
- private bool errorDialog=false;
- private IntPtr errorDialogHandle=IntPtr.Zero;
- private int redirectFlags=0;
- private bool shellExecute=true;
- private String verb="";
- private ProcessWindowStyle
windowStyle=ProcessWindowStyle.Normal;
- private String workingDir=".";
- public ProcessStartInfo()
- {
- }
! public ProcessStartInfo(String filename)
! {
! this.filename=filename;
! }
! public ProcessStartInfo(String filename, String arguments)
! {
! this.filename=filename;
! this.arguments=arguments;
! }
! public String Arguments
! {
! get
! {
! return arguments;
! }
! set
{
! arguments=value;
}
- }
! public bool CreateNoWindow
! {
! get
{
! return createNoWindow;
! }
! set
! {
! createNoWindow=value;
}
- }
! public StringDictionary EnvironmentVariables
! {
! get
{
! if(dict==null)
{
! dict=new StringDictionary();
! IDictionary
env=Environment.GetEnvironmentVariables();
! foreach(String s in env.Keys)
{
! dict.Add(s,env[s].ToString());
}
}
! return this.dict;
! }
! }
!
! public bool ErrorDialog
! {
! get
! {
! return errorDialog;
}
! set
{
! errorDialog=value;
}
! }
!
! public IntPtr ErrorDialogParentHandle
! {
! get
{
! return errorDialogHandle;
}
! set
{
! errorDialogHandle=value;
}
! }
!
! public String FileName
! {
! get
{
! return filename;
}
! set
{
! filename=value;
}
! }
!
! public bool RedirectStandardError
! {
! get
{
! return ((redirectFlags & 0x04) != 0) ;
}
! set
{
! redirectFlags = redirectFlags | (value ? 0x04
: 0x00);
}
! }
!
! public bool RedirectStandardInput
! {
! get
{
! return ((redirectFlags & 0x02)!=0);
}
! set
{
! redirectFlags = redirectFlags | (value ? 0x02 :
0x00);
}
! }
!
! public bool RedirectStandardOutput
! {
! get
{
! return ((redirectFlags & 0x01)!=0);
}
! set
{
! redirectFlags = redirectFlags | (value ? 0x01 :
0x00);
}
! }
!
! public bool UseShellExecute
! {
! get
{
! return shellExecute;
}
! set
{
! shellExecute=value;
}
- }
! public String Verb
! {
! get
{
! return verb;
! }
! set
! {
! verb=value;
! }
! }
! // huh ? ... what does this do ?
! [TODO]
! public String[] Verbs
! {
! get
! {
! throw new NotImplementedException("Verbs");
! }
! }
! public ProcessWindowStyle WindowStyle
! {
! get
! {
! return windowStyle;
! }
! set
! {
! windowStyle=value;
}
- }
! public String WorkingDirectory
! {
! get
{
! return workingDir;
}
! set
{
! workingDir=value;
}
- }
! }
! }//namespace
--- 20,485 ----
*/
namespace System.Diagnostics
{
! #if !ECMA_COMPAT
! using System.ComponentModel;
! using System.Collections;
! using System.Collections.Specialized;
! using System.Text;
! public class ProcessStartInfo
! {
! // Special flags for starting processes.
! [Flags]
! internal enum ProcessStartFlags
! {
! CreateNoWindow = 0x0001,
! ErrorDialog = 0x0002,
! RedirectStdin = 0x0004,
! RedirectStdout = 0x0008,
! RedirectStderr = 0x0010,
! UseShellExecute = 0x0020,
! ExecOverTop = 0x0040
!
! }; // enum ProcessStartFlags
!
! // Internal state.
! private String arguments;
! private String fileName;
! internal ProcessStartFlags flags;
! internal StringDictionary envVars;
! private IntPtr errorDialogParent;
! private String verb;
! private ProcessWindowStyle style;
! private String workingDirectory;
!
! // Constructors.
! public ProcessStartInfo() : this(null, null) {}
! public ProcessStartInfo(String fileName) : this(fileName, null) {}
! public ProcessStartInfo(String fileName, String arguments)
! {
! this.fileName = fileName;
! this.arguments = arguments;
! this.flags = ProcessStartFlags.UseShellExecute;
! }
!
! // Get a process start flag.
! private bool GetFlag(ProcessStartFlags flag)
{
! return ((flags & flag) != 0);
}
! // Set a process start flag.
! private void SetFlag(ProcessStartFlags flag, bool value)
{
! if(value)
! {
! flags |= flag;
! }
! else
! {
! flags &= ~flag;
! }
}
! // Get or set object properties.
! public String Arguments
{
! get
{
! if(arguments == null)
! {
! return String.Empty;
! }
! else
{
! return arguments;
}
}
! set
! {
! arguments = value;
! }
}
! public bool CreateNoWindow
{
! get
! {
! return
GetFlag(ProcessStartFlags.CreateNoWindow);
! }
! set
! {
!
SetFlag(ProcessStartFlags.CreateNoWindow, value);
! }
}
! public StringDictionary EnvironmentVariables
{
! get
! {
! if(envVars == null)
! {
! envVars = new
StringDictionary();
! IDictionary env =
Environment.GetEnvironmentVariables();
! if(env != null)
! {
! IDictionaryEnumerator e
= env.GetEnumerator();
! while(e.MoveNext())
! {
!
envVars.Add((String)(e.Key), (String)(e.Value));
! }
! }
! }
! return envVars;
! }
}
! public bool ErrorDialog
{
! get
! {
! return
GetFlag(ProcessStartFlags.ErrorDialog);
! }
! set
! {
! SetFlag(ProcessStartFlags.ErrorDialog,
value);
! }
}
! public IntPtr ErrorDialogParentHandle
{
! get
! {
! return errorDialogParent;
! }
! set
! {
! errorDialogParent = value;
! }
}
! public String FileName
{
! get
! {
! if(fileName == null)
! {
! return String.Empty;
! }
! else
! {
! return fileName;
! }
! }
! set
! {
! fileName = value;
! }
}
! public bool RedirectStandardError
{
! get
! {
! return
GetFlag(ProcessStartFlags.RedirectStderr);
! }
! set
! {
!
SetFlag(ProcessStartFlags.RedirectStderr, value);
! }
}
! public bool RedirectStandardInput
{
! get
! {
! return
GetFlag(ProcessStartFlags.RedirectStdin);
! }
! set
! {
!
SetFlag(ProcessStartFlags.RedirectStdin, value);
! }
}
! public bool RedirectStandardOutput
{
! get
! {
! return
GetFlag(ProcessStartFlags.RedirectStdout);
! }
! set
! {
!
SetFlag(ProcessStartFlags.RedirectStdout, value);
! }
}
! public bool UseShellExecute
{
! get
! {
! return
GetFlag(ProcessStartFlags.UseShellExecute);
! }
! set
! {
!
SetFlag(ProcessStartFlags.UseShellExecute, value);
! }
}
! public String Verb
{
! get
! {
! if(verb == null)
! {
! return String.Empty;
! }
! else
! {
! return verb;
! }
! }
! set
! {
! verb = value;
! }
}
! public String[] Verbs
{
! get
! {
! // We don't use verb lists in this
implementation.
! return new String [0];
! }
}
! public ProcessWindowStyle WindowStyle
{
! get
! {
! return style;
! }
! set
! {
! if(((int)value) <
((int)(ProcessWindowStyle.Normal)) ||
! ((int)value) >
((int)(ProcessWindowStyle.Maximized)))
! {
! throw new
InvalidEnumArgumentException
! ("value", (int)value,
typeof(ProcessWindowStyle));
! }
! style = value;
! }
}
! public String WorkingDirectory
{
! get
! {
! if(workingDirectory == null)
! {
! return String.Empty;
! }
! else
! {
! return workingDirectory;
! }
! }
! set
! {
! workingDirectory = value;
! }
}
! // Quote a string if necessary.
! private static String Quote(String str)
{
! // Handle the empty string case first.
! if(str == null || str == String.Empty)
! {
! return "\"\"";
! }
! // Determine if there is a character that needs
quoting.
! bool quote = false;
! foreach(char ch in str)
! {
! if(Char.IsWhiteSpace(ch) || ch == '"'
|| ch == '\'')
! {
! quote = true;
! break;
! }
! }
! if(!quote)
! {
! return str;
! }
! // Quote the string and return it.
! StringBuilder builder = new StringBuilder();
! builder.Append('"');
! foreach(char ch2 in str)
! {
! if(ch2 == '"')
! {
! builder.Append('"');
! builder.Append('"');
! }
! else
! {
! builder.Append(ch2);
! }
! }
! builder.Append('"');
! return builder.ToString();
}
! // Convert an argv array into an argument string, with appropriate
quoting.
! internal static String ArgVToArguments
! (String[] argv, int startIndex, String
separator)
{
! if(argv == null)
! {
! return String.Empty;
! }
! StringBuilder builder = new StringBuilder();
! int index = startIndex;
! while(index < argv.Length)
! {
! if(index > startIndex)
! {
! builder.Append(separator);
! }
! builder.Append(Quote(argv[index]));
! ++index;
! }
! return builder.ToString();
}
!
! // Convert an argument string into an argv array, undoing quoting.
! internal static String[] ArgumentsToArgV(String arguments)
{
! // Handle the null case first.
! if(arguments == null)
! {
! return new String [0];
! }
!
! // Count the number of arguments in the string.
! int count = 0;
! int posn = 0;
! char ch, quotech;
! while(posn < arguments.Length)
! {
! ch = arguments[posn];
! if(Char.IsWhiteSpace(ch))
! {
! ++posn;
! continue;
! }
! if(ch == '"' || ch == '\'')
! {
! // Start of a quoted argument.
! ++posn;
! quotech = ch;
! while(posn < arguments.Length)
! {
! ch = arguments[posn];
! if(ch == quotech)
! {
! if((posn + 1) <
arguments.Length &&
!
arguments[posn + 1] == quotech)
! {
! //
Escaped quote character.
! ++posn;
! }
! else
! {
! // End
of quoted sequence.
! ++posn;
! break;
! }
! }
! ++posn;
! }
! }
! else
! {
! // Start of an unquoted
argument.
! while(posn < arguments.Length)
! {
! ch = arguments[posn];
!
if(Char.IsWhiteSpace(ch) ||
! ch == '"' || ch ==
'\'')
! {
! break;
! }
! ++posn;
! }
! }
! }
!
! // Create the argument array and populate it.
! String[] argv = new String [count];
! StringBuilder builder;
! int start;
! count = 0;
! posn = 0;
! while(posn < arguments.Length)
! {
! ch = arguments[posn];
! if(Char.IsWhiteSpace(ch))
! {
! ++posn;
! continue;
! }
! if(ch == '"' || ch == '\'')
! {
! // Start of a quoted argument.
! ++posn;
! quotech = ch;
! builder = new StringBuilder();
! while(posn < arguments.Length)
! {
! ch = arguments[posn];
! if(ch == quotech)
! {
! if((posn + 1) <
arguments.Length &&
!
arguments[posn + 1] == quotech)
! {
! //
Escaped quote character.
!
builder.Append(ch);
! ++posn;
! }
! else
! {
! // End
of quoted sequence.
! ++posn;
! break;
! }
! }
! else
! {
!
builder.Append(ch);
! }
! ++posn;
! }
! argv[count++] =
builder.ToString();
! }
! else
! {
! // Start of an unquoted
argument.
! start = posn;
! while(posn < arguments.Length)
! {
! ch = arguments[posn];
!
if(Char.IsWhiteSpace(ch) ||
! ch == '"' || ch ==
'\'')
! {
! break;
! }
! ++posn;
! }
! argv[count++] =
arguments.Substring
! (start, posn - start);
! }
! }
!
! // Return the argument array to the caller.
! return argv;
}
! }; // class ProcessStartInfo
!
! #endif // !ECMA_COMPAT
!
! }; // namespace System.Diagnostics
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/System/Diagnostics EventLogTraceListener.cs,NONE,1.1 ICollectData.cs,NONE,1.1 PerformanceCounterManager.cs,NONE,1.1 ProcessModule.cs,NONE,1.1 ProcessModuleCollection.cs,NONE,1.1 ProcessThread.cs,NONE,1.1 ProcessThreadCollection.cs,NONE,1.1 Process.cs,1.3,1.4 ProcessStartInfo.cs,1.1,1.2,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.826,1.827
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/resources/en_US/System Arg.txt,1.14,1.15 Invalid.txt,1.5,1.6 NotSupp.txt,1.2,1.3
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.826,1.827
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/resources/en_US/System Arg.txt,1.14,1.15 Invalid.txt,1.5,1.6 NotSupp.txt,1.2,1.3
- Index(es):