9a9176339786cca19b01417588c37c083c594bb1
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing / TestRectangleConverter.cs
1 //
2 // Tests for System.Drawing.RectangleConverter.cs 
3 //
4 // Author:
5 //      Ravindra (rkumar@novell.com)
6 //
7
8 //
9 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System;
32 using System.Collections;
33 using System.ComponentModel;
34 using System.ComponentModel.Design.Serialization;
35 using System.Drawing;
36 using System.Globalization;
37 using System.Security.Permissions;
38 using System.Threading;
39
40 using NUnit.Framework;
41
42 namespace MonoTests.System.Drawing
43 {
44         [TestFixture]
45         [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
46         public class RectangleConverterTest
47         {
48                 Rectangle rect;
49                 Rectangle rectneg;
50                 RectangleConverter rconv;
51                 String rectStrInvariant;
52                 String rectnegStrInvariant;
53
54                 [SetUp]
55                 public void SetUp ()
56                 {
57                         rect = new Rectangle (10, 10, 20, 30);
58                         rectStrInvariant = rect.X + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " +
59                         rect.Y + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " +
60                         rect.Width + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " + 
61                         rect.Height;
62
63                         rectneg = new Rectangle (-10, -10, 20, 30);
64                         rectnegStrInvariant = rectneg.X + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " 
65                         + rectneg.Y + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " + 
66                         rectneg.Width + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " + rectneg.Height;
67
68                         rconv = (RectangleConverter) TypeDescriptor.GetConverter (rect);
69                 }
70
71                 [Test]
72 #if TARGET_JVM
73                 [NUnit.Framework.Category ("NotWorking")]
74 #endif
75                 public void TestCanConvertFrom ()
76                 {
77                         Assert.IsTrue (rconv.CanConvertFrom (typeof (String)), "CCF#1");
78                         Assert.IsTrue (rconv.CanConvertFrom (null, typeof (String)), "CCF#2");
79                         Assert.IsFalse (rconv.CanConvertFrom (null, typeof (Rectangle)), "CCF#3");
80                         Assert.IsFalse (rconv.CanConvertFrom (null, typeof (RectangleF)), "CCF#4");
81                         Assert.IsFalse (rconv.CanConvertFrom (null, typeof (Point)), "CCF#5");
82                         Assert.IsFalse (rconv.CanConvertFrom (null, typeof (PointF)), "CCF#6");
83                         Assert.IsFalse (rconv.CanConvertFrom (null, typeof (Size)), "CCF#7");
84                         Assert.IsFalse (rconv.CanConvertFrom (null, typeof (SizeF)), "CCF#8");
85                         Assert.IsFalse (rconv.CanConvertFrom (null, typeof (Object)), "CCF#9");
86                         Assert.IsFalse (rconv.CanConvertFrom (null, typeof (int)), "CCF#10");
87                         Assert.IsTrue (rconv.CanConvertFrom (null, typeof (InstanceDescriptor)), "CCF#11");
88                 }
89
90                 [Test]
91                 public void TestCanConvertTo ()
92                 {
93                         Assert.IsTrue (rconv.CanConvertTo (typeof (String)), "CCT#1");
94                         Assert.IsTrue (rconv.CanConvertTo (null, typeof (String)), "CCT#2");
95                         Assert.IsFalse (rconv.CanConvertTo (null, typeof (Rectangle)), "CCT#3");
96                         Assert.IsFalse (rconv.CanConvertTo (null, typeof (RectangleF)), "CCT#4");
97                         Assert.IsFalse (rconv.CanConvertTo (null, typeof (Point)), "CCT#5");
98                         Assert.IsFalse (rconv.CanConvertTo (null, typeof (PointF)), "CCT#6");
99                         Assert.IsFalse (rconv.CanConvertTo (null, typeof (Size)), "CCT#7");
100                         Assert.IsFalse (rconv.CanConvertTo (null, typeof (SizeF)), "CCT#8");
101                         Assert.IsFalse (rconv.CanConvertTo (null, typeof (Object)), "CCT#9");
102                         Assert.IsFalse (rconv.CanConvertTo (null, typeof (int)), "CCT#10");
103                 }
104
105                 [Test]
106 #if TARGET_JVM
107                 [NUnit.Framework.Category ("NotWorking")]
108 #endif
109                 public void TestConvertFrom ()
110                 {
111                         Assert.AreEqual (rect, (Rectangle) rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
112                                                                 "10, 10, 20, 30"), "CF#1");
113                         Assert.AreEqual (rectneg, (Rectangle) rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
114                                                                 "-10, -10, 20, 30"), "CF#2");
115
116                         try {
117                                 rconv.ConvertFrom (null, CultureInfo.InvariantCulture, 
118                                                    "10, 10");
119                                 Assert.Fail ("CF#3: must throw ArgumentException");
120                         } catch (Exception e) {
121                                 Assert.IsTrue (e is ArgumentException, "CF#3");
122                         }
123
124                         try {
125                                 rconv.ConvertFrom ("10");
126                                 Assert.Fail ("CF#3a: must throw ArgumentException");
127                         } catch (Exception e) {
128                                 Assert.IsTrue (e is ArgumentException, "CF#3a");
129                         }
130
131                         try {
132                                 rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
133                                                    "1, 1, 1, 1, 1");
134                                 Assert.Fail ("CF#4: must throw ArgumentException");
135                         } catch (Exception e) {
136                                 Assert.IsTrue (e is ArgumentException, "CF#4");
137                         }
138
139                         try {
140                                 rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
141                                                    "*1, 1, 1, 1");
142                                 Assert.Fail ("CF#5: must throw Exception");
143                         } catch (Exception ex) {
144                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "CF#5-2");
145                                 Assert.IsNotNull (ex.InnerException, "CF#5-3");
146                                 Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "CF#5-4");
147                         }
148
149                         try {
150                                 rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
151                                                    new Rectangle (10, 10, 100, 100));
152                                 Assert.Fail ("CF#6: must throw NotSupportedException");
153                         } catch (Exception e) {
154                                 Assert.IsTrue (e is NotSupportedException, "CF#6");
155                         }
156
157                         try {
158                                 rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
159                                                    new RectangleF (10, 10, 100, 100));
160                                 Assert.Fail ("CF#7: must throw NotSupportedException");
161                         } catch (Exception e) {
162                                 Assert.IsTrue (e is NotSupportedException, "CF#7");
163                         }
164
165                         try {
166                                 rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
167                                                    new Point (10, 10));
168                                 Assert.Fail ("CF#8: must throw NotSupportedException");
169                         } catch (Exception e) {
170                                 Assert.IsTrue (e is NotSupportedException, "CF#8");
171                         }
172
173                         try {
174                                 rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
175                                                    new PointF (10, 10));
176                                 Assert.Fail ("CF#9: must throw NotSupportedException");
177                         } catch (Exception e) {
178                                 Assert.IsTrue (e is NotSupportedException, "CF#9");
179                         }
180
181                         try {
182                                 rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
183                                                    new Size (10, 10));
184                                 Assert.Fail ("CF#10: must throw NotSupportedException");
185                         } catch (Exception e) {
186                                 Assert.IsTrue (e is NotSupportedException, "CF#10");
187                         }
188
189                         try {
190                                 rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
191                                                    new SizeF (10, 10));
192                                 Assert.Fail ("CF#11: must throw NotSupportedException");
193                         } catch (Exception e) {
194                                 Assert.IsTrue (e is NotSupportedException, "CF#11");
195                         }
196
197                         try {
198                                 rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
199                                                    new Object ());
200                                 Assert.Fail ("CF#12: must throw NotSupportedException");
201                         } catch (Exception e) {
202                                 Assert.IsTrue (e is NotSupportedException, "CF#12");
203                         }
204
205                         try {
206                                 rconv.ConvertFrom (null, CultureInfo.InvariantCulture, 1001);
207                                 Assert.Fail ("CF#13: must throw NotSupportedException");
208                         } catch (Exception e) {
209                                 Assert.IsTrue (e is NotSupportedException, "CF#13");
210                         }
211                 }
212
213                 [Test]
214                 public void TestConvertTo ()
215                 {
216                         Assert.AreEqual (rectStrInvariant, (String) rconv.ConvertTo (null,
217                                 CultureInfo.InvariantCulture, rect, typeof (String)), "CT#1");
218                         Assert.AreEqual (rectnegStrInvariant, (String) rconv.ConvertTo (null,
219                                 CultureInfo.InvariantCulture, rectneg, typeof (String)), "CT#2");
220
221                         try {
222                                 rconv.ConvertTo (null, CultureInfo.InvariantCulture, 
223                                                  rect, typeof (Rectangle));
224                                 Assert.Fail ("CT#3: must throw NotSupportedException");
225                         } catch (Exception e) {
226                                 Assert.IsTrue (e is NotSupportedException, "CT#3");
227                         }
228
229                         try {
230                                 rconv.ConvertTo (null, CultureInfo.InvariantCulture,
231                                                  rect, typeof (RectangleF));
232                                 Assert.Fail ("CT#4: must throw NotSupportedException");
233                         } catch (Exception e) {
234                                 Assert.IsTrue (e is NotSupportedException, "CT#4");
235                         }
236
237                         try {
238                                 rconv.ConvertTo (null, CultureInfo.InvariantCulture,
239                                                  rect, typeof (Size));
240                                 Assert.Fail ("CT#5: must throw NotSupportedException");
241                         } catch (Exception e) {
242                                 Assert.IsTrue (e is NotSupportedException, "CT#5");
243                         }
244
245                         try {
246                                 rconv.ConvertTo (null, CultureInfo.InvariantCulture,
247                                                  rect, typeof (SizeF));
248                                 Assert.Fail ("CT#6: must throw NotSupportedException");
249                         } catch (Exception e) {
250                                 Assert.IsTrue (e is NotSupportedException, "CT#6");
251                         }
252
253                         try {
254                                 rconv.ConvertTo (null, CultureInfo.InvariantCulture,
255                                                  rect, typeof (Point));
256                                 Assert.Fail ("CT#7: must throw NotSupportedException");
257                         } catch (Exception e) {
258                                 Assert.IsTrue (e is NotSupportedException, "CT#7");
259                         }
260
261                         try {
262                                 rconv.ConvertTo (null, CultureInfo.InvariantCulture,
263                                                  rect, typeof (PointF));
264                                 Assert.Fail ("CT#8: must throw NotSupportedException");
265                         } catch (Exception e) {
266                                 Assert.IsTrue (e is NotSupportedException, "CT#8");
267                         }
268
269                         try {
270                                 rconv.ConvertTo (null, CultureInfo.InvariantCulture,
271                                                  rect, typeof (Object));
272                                 Assert.Fail ("CT#9: must throw NotSupportedException");
273                         } catch (Exception e) {
274                                 Assert.IsTrue (e is NotSupportedException, "CT#9");
275                         }
276
277                         try {
278                                 rconv.ConvertTo (null, CultureInfo.InvariantCulture,
279                                                  rect, typeof (int));
280                                 Assert.Fail ("CT#10: must throw NotSupportedException");
281                         } catch (Exception e) {
282                                 Assert.IsTrue (e is NotSupportedException, "CT#10");
283                         }
284                 }
285
286                 [Test]
287                 public void TestGetCreateInstanceSupported ()
288                 {
289                         Assert.IsTrue (rconv.GetCreateInstanceSupported (), "GCIS#1");
290                         Assert.IsTrue (rconv.GetCreateInstanceSupported (null), "GCIS#2");
291                 }
292
293                 [Test]
294                 public void TestCreateInstance ()
295                 {
296                         Rectangle rectInstance;
297
298                         Hashtable ht = new Hashtable ();
299                         ht.Add ("X", 10); ht.Add ("Y", 10);
300                         ht.Add ("Width", 20); ht.Add ("Height", 30);
301
302                         rectInstance = (Rectangle) rconv.CreateInstance (ht);
303                         Assert.AreEqual (rect, rectInstance, "CI#1");
304
305                         ht.Clear ();
306                         ht.Add ("X", -10); ht.Add ("Y", -10);
307                         ht.Add ("Width", 20); ht.Add ("Height", 30);
308
309                         rectInstance = (Rectangle) rconv.CreateInstance (null, ht);
310                         Assert.AreEqual (rectneg, rectInstance, "CI#2");
311                 }
312
313                 [Test]
314 #if NET_2_0
315                 [ExpectedException (typeof (ArgumentException))]
316 #else
317                 [ExpectedException (typeof (NullReferenceException))]
318 #endif
319                 public void TestCreateInstance_CaseSensitive ()
320                 {
321                         Hashtable ht = new Hashtable ();
322                         ht.Add ("x", -10);
323                         ht.Add ("Y", -10);
324                         ht.Add ("Width", 20);
325                         ht.Add ("Height", 30);
326                         rconv.CreateInstance (null, ht);
327                 }
328
329                 [Test]
330                 public void TestGetPropertiesSupported ()
331                 {
332                         Assert.IsTrue (rconv.GetPropertiesSupported (), "GPS#1");
333                         Assert.IsTrue (rconv.GetPropertiesSupported (null), "GPS#2");
334                 }
335
336                 [Test]
337 #if TARGET_JVM
338                 [NUnit.Framework.Category ("NotWorking")]
339 #endif
340                 public void TestGetProperties ()
341                 {
342                         Attribute [] attrs;
343                         PropertyDescriptorCollection propsColl;
344
345                         propsColl = rconv.GetProperties (rect);
346                         Assert.AreEqual (4, propsColl.Count, "GP1#1");
347                         Assert.AreEqual (rect.X, propsColl["X"].GetValue (rect), "GP1#2");
348                         Assert.AreEqual (rect.Y, propsColl["Y"].GetValue (rect), "GP1#3");
349                         Assert.AreEqual (rect.Width, propsColl["Width"].GetValue (rect), "GP1#4");
350                         Assert.AreEqual (rect.Height, propsColl["Height"].GetValue (rect), "GP1#5");
351
352                         propsColl = rconv.GetProperties (null, rectneg);
353                         Assert.AreEqual (4, propsColl.Count, "GP2#1");
354                         Assert.AreEqual (rectneg.X, propsColl["X"].GetValue (rectneg), "GP2#2");
355                         Assert.AreEqual (rectneg.Y, propsColl["Y"].GetValue (rectneg), "GP2#3");
356                         Assert.AreEqual (rectneg.Width, propsColl["Width"].GetValue (rectneg), "GP2#4");
357                         Assert.AreEqual (rectneg.Height, propsColl["Height"].GetValue (rectneg), "GP2#5");
358
359                         propsColl = rconv.GetProperties (null, rect, null);
360                         Assert.AreEqual (11, propsColl.Count, "GP3#1");
361                         Assert.AreEqual (rect.X, propsColl["X"].GetValue (rect), "GP3#2");
362                         Assert.AreEqual (rect.Y, propsColl["Y"].GetValue (rect), "GP3#3");
363                         Assert.AreEqual (rect.Width, propsColl["Width"].GetValue (rect), "GP3#4");
364                         Assert.AreEqual (rect.Height, propsColl["Height"].GetValue (rect), "GP3#5");
365
366                         Assert.AreEqual (rect.Top, propsColl["Top"].GetValue (rect), "GP3#6");
367                         Assert.AreEqual (rect.Bottom, propsColl["Bottom"].GetValue (rect), "GP3#7");
368                         Assert.AreEqual (rect.Left, propsColl["Left"].GetValue (rect), "GP3#8");
369                         Assert.AreEqual (rect.Right, propsColl["Right"].GetValue (rect), "GP3#9");
370                         Assert.AreEqual (rect.Location, propsColl["Location"].GetValue (rect), "GP3#10");
371                         Assert.AreEqual (rect.Size, propsColl["Size"].GetValue (rect), "GP3#11");
372                         Assert.AreEqual (rect.IsEmpty, propsColl["IsEmpty"].GetValue (rect), "GP3#12");
373
374                         Type type = typeof (Rectangle);
375                         attrs = Attribute.GetCustomAttributes (type, true);
376                         propsColl = rconv.GetProperties (null, rect, attrs);
377                         Assert.AreEqual (0, propsColl.Count, "GP3#13");
378                 }
379
380                 [Test]
381                 public void ConvertFromInvariantString_string ()
382                 {
383                         Assert.AreEqual (rect, rconv.ConvertFromInvariantString (rectStrInvariant),
384                                 "CFISS#1");
385                         Assert.AreEqual (rectneg, rconv.ConvertFromInvariantString (rectnegStrInvariant),
386                                 "CFISS#2");
387                 }
388
389                 [Test]
390                 [ExpectedException (typeof (ArgumentException))]
391                 public void ConvertFromInvariantString_string_exc_1 ()
392                 {
393                         rconv.ConvertFromInvariantString ("1, 2, 3");
394                 }
395
396                 [Test]
397 #if TARGET_JVM
398                 [NUnit.Framework.Category ("NotWorking")]
399 #endif
400                 public void ConvertFromInvariantString_string_exc_2 ()
401                 {
402                         try {
403                                 rconv.ConvertFromInvariantString ("hello");
404                                 Assert.Fail ("#1");
405                         } catch (Exception ex) {
406                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
407                                 Assert.IsNotNull (ex.InnerException, "#3");
408                                 Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
409                         }
410                 }
411
412                 [Test]
413 #if TARGET_JVM
414                 [NUnit.Framework.Category ("NotWorking")]
415 #endif
416                 public void ConvertFromString_string ()
417                 {
418                         // save current culture
419                         CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
420
421                         try {
422                                 PerformConvertFromStringTest (new CultureInfo ("en-US"));
423                                 PerformConvertFromStringTest (new CultureInfo ("nl-BE"));
424                                 PerformConvertFromStringTest (new MyCultureInfo ());
425                         } finally {
426                                 // restore original culture
427                                 Thread.CurrentThread.CurrentCulture = currentCulture;
428                         }
429                 }
430
431                 [Test]
432                 [ExpectedException (typeof (ArgumentException))]
433                 public void ConvertFromString_string_exc_1 ()
434                 {
435                         CultureInfo culture = CultureInfo.CurrentCulture;
436                         rconv.ConvertFromString (string.Format(culture,
437                                 "1{0} 2{0} 3{0} 4{0} 5", culture.TextInfo.ListSeparator));
438                 }
439
440                 [Test]
441 #if TARGET_JVM
442                 [NUnit.Framework.Category ("NotWorking")]
443 #endif
444                 public void ConvertFromString_string_exc_2 ()
445                 {
446                         try {
447                                 rconv.ConvertFromString ("hello");
448                                 Assert.Fail ("#1");
449                         } catch (Exception ex) {
450                                 Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
451                                 Assert.IsNotNull (ex.InnerException, "#3");
452                                 Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
453                         }
454                 }
455
456                 [Test]
457                 public void ConvertToInvariantString_string ()
458                 {
459                         Assert.AreEqual (rectStrInvariant, rconv.ConvertToInvariantString (rect),
460                                 "CFISS#1");
461                         Assert.AreEqual (rectnegStrInvariant, rconv.ConvertToInvariantString (rectneg),
462                                 "CFISS#2");
463                 }
464
465                 [Test]
466                 public void ConvertToString_string () {
467                         // save current culture
468                         CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
469
470                         try {
471                                 PerformConvertToStringTest (new CultureInfo ("en-US"));
472                                 PerformConvertToStringTest (new CultureInfo ("nl-BE"));
473                                 PerformConvertToStringTest (new MyCultureInfo ());
474                         } finally {
475                                 // restore original culture
476                                 Thread.CurrentThread.CurrentCulture = currentCulture;
477                         }
478                 }
479
480                 [Test]
481                 public void GetStandardValuesSupported ()
482                 {
483                         Assert.IsFalse (rconv.GetStandardValuesSupported ());
484                 }
485
486                 [Test]
487                 public void GetStandardValues ()
488                 {
489                         Assert.IsNull (rconv.GetStandardValues ());
490                 }
491
492                 [Test]
493                 public void GetStandardValuesExclusive ()
494                 {
495                         Assert.IsFalse (rconv.GetStandardValuesExclusive ());
496                 }
497
498                 private void PerformConvertFromStringTest (CultureInfo culture)
499                 {
500                         // set current culture
501                         Thread.CurrentThread.CurrentCulture = culture;
502
503                         // perform tests
504                         Assert.AreEqual (rect, rconv.ConvertFromString (CreateRectangleString (rect)),
505                                 "CFSS#1-" + culture.Name);
506                         Assert.AreEqual (rectneg, rconv.ConvertFromString (CreateRectangleString (rectneg)),
507                                 "CFSS#2-" + culture.Name);
508                 }
509
510                 private void PerformConvertToStringTest (CultureInfo culture)
511                 {
512                         // set current culture
513                         Thread.CurrentThread.CurrentCulture = culture;
514
515                         // perform tests
516                         Assert.AreEqual (CreateRectangleString (rect), rconv.ConvertToString (rect),
517                                 "CFISS#1-" + culture.Name);
518                         Assert.AreEqual (CreateRectangleString (rectneg), rconv.ConvertToString (rectneg),
519                                 "CFISS#2-" + culture.Name);
520                 }
521
522                 private static string CreateRectangleString (Rectangle rectangle)
523                 {
524                         return CreateRectangleString (CultureInfo.CurrentCulture, rectangle);
525                 }
526
527                 private static string CreateRectangleString (CultureInfo culture, Rectangle rectangle)
528                 {
529                         return string.Format ("{0}{1} {2}{1} {3}{1} {4}", rectangle.X.ToString (culture),
530                                 culture.TextInfo.ListSeparator, rectangle.Y.ToString (culture),
531                                 rectangle.Width.ToString (culture), rectangle.Height.ToString (culture));
532                 }
533
534                 [Serializable]
535                 private sealed class MyCultureInfo : CultureInfo
536                 {
537                         internal MyCultureInfo ()
538                                 : base ("en-US")
539                         {
540                         }
541
542                         public override object GetFormat (Type formatType)
543                         {
544                                 if (formatType == typeof (NumberFormatInfo)) {
545                                         NumberFormatInfo nfi = (NumberFormatInfo) ((NumberFormatInfo) base.GetFormat (formatType)).Clone ();
546
547                                         nfi.NegativeSign = "myNegativeSign";
548                                         return NumberFormatInfo.ReadOnly (nfi);
549                                 } else {
550                                         return base.GetFormat (formatType);
551                                 }
552                         }
553                 }
554         }
555 }