2006-09-30 Marek Sieradzki <marek.sieradzki@gmail.com>
[mono.git] / mcs / tools / xbuild / LoggerInfo.cs
1 //
2 // LoggerInfo.cs: Contains information about logger parameters.
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 //
7 // (C) 2005 Marek Sieradzki
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 #if NET_2_0
29
30 using System;
31 using System.Globalization;
32 using System.Reflection;
33 using Mono.XBuild.Framework;
34
35 namespace Mono.XBuild.CommandLine {
36         internal class LoggerInfo : AssemblyLoadInfo {
37         
38                 string  parameters;
39         
40                 public LoggerInfo ()
41                 {
42                 }
43                 
44                 public LoggerInfo (string s)
45                 {
46                         string version = null;
47                         string culture = null;
48                         string name = null;
49                         string filename = null;
50                         string loggerClass = null;
51                 
52                         string[] temp1 = s.Split (':');
53                         string[] temp2 = temp1[1].Split (',');
54                         
55                         // FIXME: replace all of this with readable code
56                         loggerClass = temp2 [0];
57                         if (temp2.Length == 4) {
58                                 name = temp2 [1];
59                                 version = temp2 [2].Split ('=') [1];
60                                 string[] temp3 = temp2 [3].Split (';');
61                                 if (temp3.Length == 1) {
62                                         culture = temp2 [3].Split ('=') [1];
63                                 }
64                                 if (temp3.Length > 1 ) {
65                                         culture = temp3 [0].Split ('=') [1];
66                                         parameters = temp3 [1];
67                                 }
68                         }
69                         if (temp2.Length == 2) {
70                                 string[] temp3 = temp2 [1].Split (';');
71                                 if (temp3 [0].EndsWith (".dll")) {
72                                         filename = temp2 [1];
73                                 } else {
74                                         name = temp2 [1];
75                                 }
76                                 if (temp3.Length > 1)
77                                         parameters = temp3 [1];
78                         }
79                         
80                         if (name != null)
81                                 SetAssemblyName (LoadInfoType.AssemblyName, null, name, version, culture, null,loggerClass);
82                         else if (filename != null)
83                                 SetAssemblyName (LoadInfoType.AssemblyFilename, filename, null, null, null, null, loggerClass);
84                 }
85                 
86                 public string Parameters {
87                         get { return parameters; }
88                 }
89         }
90 }
91
92 #endif