Improve test to handle constants of classes whose value is null
[mono.git] / mcs / class / System.Web / System.Web.Configuration / GlobalizationConfiguration.cs
1 // 
2 // System.Web.Configuration.GlobalizationConfiguration
3 //
4 // Authors:
5 //      Patrik Torstensson (ptorsten@hotmail.com)
6 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 //
8 // (c) 2003 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.Globalization;
33 using System.Text;
34
35 namespace System.Web.Configuration
36 {
37         class GlobalizationConfiguration
38         {
39                 internal Encoding RequestEncoding;
40                 internal Encoding ResponseEncoding;
41                 internal Encoding FileEncoding;
42                 internal CultureInfo Culture;
43                 internal CultureInfo UICulture;
44
45                 internal GlobalizationConfiguration (object p)
46                 {
47                         if (!(p is GlobalizationConfiguration))
48                                 return;
49
50                         GlobalizationConfiguration parent = (GlobalizationConfiguration) p;
51                         RequestEncoding = parent.RequestEncoding;
52                         ResponseEncoding = parent.ResponseEncoding;
53                         FileEncoding = parent.FileEncoding;
54                         Culture = parent.Culture;
55                         UICulture = parent.UICulture;
56                 }
57
58                 static public GlobalizationConfiguration GetInstance (HttpContext context)
59                 {
60                         GlobalizationConfiguration config;
61                         try {
62                                 if (context == null)
63                                         config = HttpContext.GetAppConfig ("system.web/globalization")
64                                                  as GlobalizationConfiguration;
65                                 else
66                                         config = context.GetConfig ("system.web/globalization")
67                                                  as GlobalizationConfiguration;
68                         } catch {
69                                 return null;
70                         }
71                         return config;
72                 }
73
74         }
75 }
76