2004-09-06 Dick Porter <dick@ximian.com>
[mono.git] / mcs / class / System / System.Diagnostics / ProcessStartInfo.cs
1 //
2 // System.Diagnostics.ProcessStartInfo.cs
3 //
4 // Authors:
5 //   Dick Porter (dick@ximian.com)
6 //   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
7 //
8 // (C) 2002 Ximian, Inc.  http://www.ximian.com
9 //
10
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 // 
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 // 
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //
31
32 using System.Collections;
33 using System.Collections.Specialized;
34 using System.ComponentModel;
35
36 namespace System.Diagnostics 
37 {
38         [TypeConverter (typeof (ExpandableObjectConverter))]
39         public sealed class ProcessStartInfo 
40         {
41
42                 private string arguments = "";
43                 private bool create_no_window = false;
44                 private bool error_dialog = false;
45                 private IntPtr error_dialog_parent_handle = (IntPtr)0;
46                 private string filename = "";
47                 private bool redirect_standard_error = false;
48                 private bool redirect_standard_input = false;
49                 private bool redirect_standard_output = false;
50                 private bool use_shell_execute = true;
51                 private string verb = "";
52                 private ProcessWindowStyle window_style = ProcessWindowStyle.Normal;
53                 private string working_directory = "";
54                 private ProcessStringDictionary envVars;
55
56                 public ProcessStartInfo() 
57                 {
58                 }
59
60                 public ProcessStartInfo(string filename) 
61                 {
62                         this.filename = filename;
63                 }
64
65                 public ProcessStartInfo(string filename, string arguments) 
66                 {
67                         this.filename = filename;
68                         this.arguments = arguments;
69                 }
70
71                 [RecommendedAsConfigurable (true), DefaultValue ("")]
72                 [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
73
74                 [MonitoringDescription ("Command line agruments for this process.")]
75                 public string Arguments {
76                         get {
77                                 return(arguments);
78                         }
79                         set {
80                                 arguments = value;
81                         }
82                 }
83                 
84                 [DefaultValue (false)]
85                 [MonitoringDescription ("Start this process with a new window.")]
86                 public bool CreateNoWindow {
87                         get {
88                                 return(create_no_window);
89                         }
90                         set {
91                                 create_no_window = value;
92                         }
93                 }
94
95                 [MonoTODO("Need to read the env block somehow")]
96                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content), DefaultValue (null)]
97                 [Editor ("System.Diagnostics.Design.StringDictionaryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
98                 [MonitoringDescription ("Environment variables used for this process.")]
99                 public StringDictionary EnvironmentVariables {
100                         get {
101                                 if (envVars == null) {
102                                         envVars = new ProcessStringDictionary ();
103                                         foreach (DictionaryEntry entry in Environment.GetEnvironmentVariables ())
104                                                 envVars.Add ((string) entry.Key, (string) entry.Value);
105                                 }
106
107                                 return envVars;
108                         }
109                 }
110                 
111                 internal bool HaveEnvVars {
112                         get { return (envVars != null && envVars.Count > 0); }
113                 }
114                 
115                 [DefaultValue (false)]
116                 [MonitoringDescription ("Thread shows dialogboxes for errors.")]
117                 public bool ErrorDialog {
118                         get {
119                                 return(error_dialog);
120                         }
121                         set {
122                                 error_dialog = value;
123                         }
124                 }
125                 
126                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden), Browsable (false)]
127                 public IntPtr ErrorDialogParentHandle {
128                         get {
129                                 return(error_dialog_parent_handle);
130                         }
131                         set {
132                                 error_dialog_parent_handle = value;
133                         }
134                 }
135                 
136                 [RecommendedAsConfigurable (true), DefaultValue ("")]
137                 [Editor ("System.Diagnostics.Design.StartFileNameEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
138                 [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
139                 [MonitoringDescription ("The name of the resource to start this process.")]
140                 public string FileName {
141                         get {
142                                 return(filename);
143                         }
144                         set {
145                                 filename = value;
146                         }
147                 }
148                 
149                 [DefaultValue (false)]
150                 [MonitoringDescription ("Errors of this process are redirected.")]
151                 public bool RedirectStandardError {
152                         get {
153                                 return(redirect_standard_error);
154                         }
155                         set {
156                                 redirect_standard_error = value;
157                         }
158                 }
159                 
160                 [DefaultValue (false)]
161                 [MonitoringDescription ("Standard input of this process is redirected.")]
162                 public bool RedirectStandardInput {
163                         get {
164                                 return(redirect_standard_input);
165                         }
166                         set {
167                                 redirect_standard_input = value;
168                         }
169                 }
170                 
171                 [DefaultValue (false)]
172                 [MonitoringDescription ("Standart output of this process is redirected.")]
173                 public bool RedirectStandardOutput {
174                         get {
175                                 return(redirect_standard_output);
176                         }
177                         set {
178                                 redirect_standard_output = value;
179                         }
180                 }
181                 
182                 [DefaultValue (true)]
183                 [MonitoringDescription ("Use the shell to start this process.")]
184                 public bool UseShellExecute {
185                         get {
186                                 return(use_shell_execute);
187                         }
188                         set {
189                                 use_shell_execute = value;
190                         }
191                 }
192                 
193                 [DefaultValue ("")]
194                 [TypeConverter ("System.Diagnostics.Design.VerbConverter, " + Consts.AssemblySystem_Design)]
195                 [MonitoringDescription ("The verb to apply to a used document.")]
196                 public string Verb {
197                         get {
198                                 return(verb);
199                         }
200                         set {
201                                 verb = value;
202                         }
203                 }
204
205                 [MonoTODO]
206                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden), Browsable (false)]
207                 public string[] Verbs {
208                         get {
209                                 return(null);
210                         }
211                 }
212                 
213                 [DefaultValue (typeof (ProcessWindowStyle), "Normal")]
214                 [MonitoringDescription ("The window style used to start this process.")]
215                 public ProcessWindowStyle WindowStyle {
216                         get {
217                                 return(window_style);
218                         }
219                         set {
220                                 window_style = value;
221                         }
222                 }
223                 
224                 [RecommendedAsConfigurable (true), DefaultValue ("")]
225                 [Editor ("System.Diagnostics.Design.WorkingDirectoryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
226                 [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
227                 [MonitoringDescription ("The initial directory for this process.")]
228                 public string WorkingDirectory {
229                         get {
230                                 return(working_directory);
231                         }
232                         set {
233                                 working_directory = value;
234                         }
235                 }
236         }
237 }