1291d4020a6545ab6f321de83b06322c2150f791
[mono.git] / mcs / class / System / System.Diagnostics / FileVersionInfo.cs
1 //
2 // System.Diagnostics.FileVersionInfo.cs
3 //
4 // Authors:
5 //   Dick Porter (dick@ximian.com)
6 //
7 // (C) 2002 Ximian, Inc.
8 //
9
10 using System;
11 using System.Runtime.CompilerServices;
12
13 namespace System.Diagnostics {
14         public sealed class FileVersionInfo {
15                 /* There is no public constructor for this class, it
16                  * is initialised by the runtime.  All the private
17                  * variables here are looked up by name, so dont
18                  * change them without also changing the runtime
19                  */
20                 private string comments;
21                 private string companyname;
22                 private string filedescription;
23                 private string filename;
24                 private string fileversion;
25                 private string internalname;
26                 private string language;
27                 private string legalcopyright;
28                 private string legaltrademarks;
29                 private string originalfilename;
30                 private string privatebuild;
31                 private string productname;
32                 private string productversion;
33                 private string specialbuild;
34                 private bool isdebug;
35                 private bool ispatched;
36                 private bool isprerelease;
37                 private bool isprivatebuild;
38                 private bool isspecialbuild;
39                 private int filemajorpart;
40                 private int fileminorpart;
41                 private int filebuildpart;
42                 private int fileprivatepart;
43                 private int productmajorpart;
44                 private int productminorpart;
45                 private int productbuildpart;
46                 private int productprivatepart;
47
48                 private FileVersionInfo() {
49                         /* This is here just to shut the compiler up */
50                         comments=null;
51                         companyname=null;
52                         filedescription=null;
53                         filename=null;
54                         fileversion=null;
55                         internalname=null;
56                         language=null;
57                         legalcopyright=null;
58                         legaltrademarks=null;
59                         originalfilename=null;
60                         privatebuild=null;
61                         productname=null;
62                         productversion=null;
63                         specialbuild=null;
64                         isdebug=false;
65                         ispatched=false;
66                         isprerelease=false;
67                         isprivatebuild=false;
68                         isspecialbuild=false;
69                         filemajorpart=0;
70                         fileminorpart=0;
71                         filebuildpart=0;
72                         fileprivatepart=0;
73                         productmajorpart=0;
74                         productminorpart=0;
75                         productbuildpart=0;
76                         productprivatepart=0;
77                 }
78                 
79                 
80                 public string Comments {
81                         get {
82                                 return(comments);
83                         }
84                 }
85
86                 public string CompanyName {
87                         get {
88                                 return(companyname);
89                         }
90                 }
91
92                 public int FileBuildPart {
93                         get {
94                                 return(filebuildpart);
95                         }
96                 }
97
98                 public string FileDescription {
99                         get {
100                                 return(filedescription);
101                         }
102                 }
103
104                 public int FileMajorPart {
105                         get {
106                                 return(filemajorpart);
107                         }
108                 }
109                 
110                 public int FileMinorPart {
111                         get {
112                                 return(fileminorpart);
113                         }
114                 }
115
116                 public string FileName {
117                         get {
118                                 return(filename);
119                         }
120                 }
121
122                 public int FilePrivatePart {
123                         get {
124                                 return(fileprivatepart);
125                         }
126                 }
127
128                 public string FileVersion {
129                         get {
130                                 return(fileversion);
131                         }
132                 }
133
134                 public string InternalName {
135                         get {
136                                 return(internalname);
137                         }
138                 }
139
140                 public bool IsDebug {
141                         get {
142                                 return(isdebug);
143                         }
144                 }
145
146                 public bool IsPatched {
147                         get {
148                                 return(ispatched);
149                         }
150                 }
151
152                 public bool IsPreRelease {
153                         get {
154                                 return(isprerelease);
155                         }
156                 }
157                 
158                 public bool IsPrivateBuild {
159                         get {
160                                 return(isprivatebuild);
161                         }
162                 }
163
164                 public bool IsSpecialBuild {
165                         get {
166                                 return(isspecialbuild);
167                         }
168                 }
169
170                 public string Language {
171                         get {
172                                 return(language);
173                         }
174                 }
175
176                 public string LegalCopyright {
177                         get {
178                                 return(legalcopyright);
179                         }
180                 }
181
182                 public string LegalTrademarks {
183                         get {
184                                 return(legaltrademarks);
185                         }
186                 }
187
188                 public string OriginalFilename {
189                         get {
190                                 return(originalfilename);
191                         }
192                 }
193
194                 public string PrivateBuild {
195                         get {
196                                 return(privatebuild);
197                         }
198                 }
199
200                 public int ProductBuildPart {
201                         get {
202                                 return(productbuildpart);
203                         }
204                 }
205
206                 public int ProductMajorPart {
207                         get {
208                                 return(productmajorpart);
209                         }
210                 }
211
212                 public int ProductMinorPart {
213                         get {
214                                 return(productminorpart);
215                         }
216                 }
217
218                 public string ProductName {
219                         get {
220                                 return(productname);
221                         }
222                 }
223
224                 public int ProductPrivatePart {
225                         get {
226                                 return(productprivatepart);
227                         }
228                 }
229
230                 public string ProductVersion {
231                         get {
232                                 return(productversion);
233                         }
234                 }
235
236                 public string SpecialBuild {
237                         get {
238                                 return(specialbuild);
239                         }
240                 }
241
242                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
243                 private extern void GetVersionInfo_internal(string fileName);
244                 
245                 public static FileVersionInfo GetVersionInfo(string fileName) {
246                         FileVersionInfo fvi=new FileVersionInfo();
247
248                         fvi.GetVersionInfo_internal(fileName);
249                         
250                         return(fvi);
251                 }
252                 
253                 public override string ToString() {
254                         string str;
255
256                         str="File:             " + filename + "\n";
257                         str+="InternalName:     " + internalname + "\n";
258                         str+="OriginalFilename: " + originalfilename + "\n";
259                         str+="FileVersion:      " + fileversion + "\n";
260                         str+="FileDescription:  " + filedescription + "\n";
261                         str+="Product:          " + productname + "\n";
262                         str+="ProductVersion:   " + productversion + "\n";
263                         str+="Debug:            " + isdebug + "\n";
264                         str+="Patched:          " + ispatched + "\n";
265                         str+="PreRelease:       " + isprerelease + "\n";
266                         str+="PrivateBuild:     " + isprivatebuild + "\n";
267                         str+="SpecialBuild:     " + isspecialbuild + "\n";
268                         str+="Language          " + language + "\n";
269                         
270                         return(str);
271                 }
272         }
273 }
274