~ubuntu-branches/ubuntu/lucid/mono/lucid

« back to all changes in this revision

Viewing changes to mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ExpressionCollection.cs

  • Committer: Bazaar Package Importer
  • Author(s): Mirco Bauer
  • Date: 2009-07-30 19:35:10 UTC
  • mto: (5.2.2 squeeze)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20090730193510-cdttfvqokq2kmdvh
Tags: upstream-2.4.2.3+dfsg
ImportĀ upstreamĀ versionĀ 2.4.2.3+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
        internal class ExpressionCollection {
42
42
        
43
43
                IList objects;
 
44
                static Dictionary<string, bool> boolValues;
 
45
 
 
46
                static ExpressionCollection ()
 
47
                {
 
48
                        string[] trueValuesArray = new string[] {"true", "on", "yes"};
 
49
                        string[] falseValuesArray = new string[] {"false", "off", "no"};
 
50
 
 
51
                        boolValues = new Dictionary<string, bool> (StringComparer.InvariantCultureIgnoreCase);
 
52
                        foreach (string s in trueValuesArray)
 
53
                                boolValues.Add (s, true);
 
54
                        foreach (string s in falseValuesArray)
 
55
                                boolValues.Add (s, false);
 
56
                }
44
57
        
45
58
                public ExpressionCollection ()
46
59
                {
100
113
 
101
114
                object ConvertToObject (string raw, Type type)
102
115
                {
103
 
                        if (type == typeof (bool))
104
 
                                return Boolean.Parse (raw);
105
 
                        else if (type == typeof (string))
 
116
                        if (type == typeof (bool)) {
 
117
                                bool value;
 
118
                                if (boolValues.TryGetValue (raw, out value))
 
119
                                        return value;
 
120
                                else
 
121
                                        return false;
 
122
                        }
 
123
 
 
124
                        if (type == typeof (string))
106
125
                                return raw;
107
126
                        else if (type == typeof (int))
108
127
                                return Int32.Parse (raw);
168
187
 
169
188
                                string str = o as string;
170
189
                                if (str != null) {
171
 
                                        if (str != ";" && prev != null && prev is ItemReference)
 
190
                                        string trimmed_str = str.Trim ();
 
191
                                        if (!IsSemicolon (str) && trimmed_str.Length > 0 && prev != null && prev is ItemReference)
 
192
                                                // non-empty, non-semicolon string after item ref
172
193
                                                ThrowCantConcatError (prev, str);
173
194
 
174
 
                                        prev_can_concat = !(str.Length > 0 && str [str.Length - 1] == ';') && str.Trim ().Length > 0;
 
195
                                        if (trimmed_str.Length == 0 && prev is string && IsSemicolon ((string) prev)) {
 
196
                                                // empty string after a ';', ignore it
 
197
                                                continue;
 
198
                                        }
 
199
 
 
200
                                        // empty string _after_ a itemref, not an error
 
201
                                        prev_can_concat = !(str.Length > 0 && str [str.Length - 1] == ';') && trimmed_str.Length > 0;
175
202
                                        AddItemsToArray (finalItems,
176
203
                                                        ConvertToITaskItemArrayFromString (str),
177
204
                                                        can_concat);
250
277
                        return items.ToArray ();
251
278
                }
252
279
 
 
280
                bool IsSemicolon (string str)
 
281
                {
 
282
                        return str != null && str.Length == 1 && str [0] == ';';
 
283
                }
 
284
 
253
285
                void ThrowCantConcatError (object first, object second)
254
286
                {
255
287
                        throw new Exception (String.Format (