Author: kostat
Date: 2007-12-27 09:27:55 -0500 (Thu, 27 Dec 2007)
New Revision: 91938
Modified:
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs
Log:
Add support for java config files settings inside the .Net appSettings
Modified:
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs
===================================================================
---
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs
2007-12-27 14:19:01 UTC (rev 91937)
+++
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs
2007-12-27 14:27:55 UTC (rev 91938)
@@ -48,6 +48,7 @@
static IInternalConfigConfigurationFactory configFactory;
static Hashtable configurations = Hashtable.Synchronized (new
Hashtable ());
#else
+ static readonly object AppSettingsKey = new object ();
static internal IInternalConfigConfigurationFactory
configFactory
{
get{
@@ -272,7 +273,35 @@
return null;
#if TARGET_J2EE
- return get_runtime_object.Invoke (section, new object
[0]);
+ object value = get_runtime_object.Invoke (section, new
object [0]);
+ if (String.CompareOrdinal ("appSettings", sectionName)
== 0) {
+ HttpContext hc = HttpContext.Current;
+ NameValueCollection collection =
(NameValueCollection) hc.Items [AppSettingsKey];
+
+ if (collection == null) {
+ IServiceProvider provider =
(IServiceProvider) ((IServiceProvider) hc).GetService (typeof
(HttpWorkerRequest));
+ javax.servlet.ServletConfig config =
(javax.servlet.ServletConfig) provider.GetService (typeof
(javax.servlet.ServletConfig));
+ javax.servlet.ServletContext context =
config.getServletContext ();
+
+ collection = new NameValueCollection
((NameValueCollection)value);
+
+ for (java.util.Enumeration e =
context.getInitParameterNames (); e.hasMoreElements (); ) {
+ string key = (string)
e.nextElement ();
+ collection.Add (key,
context.getInitParameter (key));
+ }
+
+ for (java.util.Enumeration e =
config.getInitParameterNames (); e.hasMoreElements (); ) {
+ string key = (string)
e.nextElement ();
+ collection.Add (key,
config.getInitParameter (key));
+ }
+
+ hc.Items [AppSettingsKey] = collection;
+ }
+
+ value = collection;
+ }
+
+ return value;
#else
return SettingsMappingManager.MapSection
(get_runtime_object.Invoke (section, new object [0]));
#endif
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches