Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Habersack <grendel@twistedcode.net>2008-03-01 02:49:18 +0300
committerMarek Habersack <grendel@twistedcode.net>2008-03-01 02:49:18 +0300
commit09c2c620cb69444ed4e9427d6e9e852351009e75 (patch)
treea76a100f2db095af2f6391be947a6a42334b1e78 /mcs/class/Mono.Web
parent9a2bcff65d98f459abb62703a5666af8eda2bde0 (diff)
parent1ed304478602879e3d3788d12592841045c56c79 (diff)
2008-03-01 Marek Habersack <mhabersack@novell.com>
* HttpRuntime.cs: SettingsMappingManager has been moved to Mono.Web. 2008-03-01 Marek Habersack <mhabersack@novell.com> * WebConfigurationManager.cs: SettingsMappingManager has been moved to Mono.Web.dll 2008-03-01 Marek Habersack <mhabersack@novell.com> * Makefile: added a dependency on Mono.Web.dll * System.Web.dll.sources: removed SystemSettingsMapper public APIs and moved them to the Mono.Web assembly. 2008-03-01 Marek Habersack <mhabersack@novell.com> * AssemblyInfo.cs: added 2008-03-01 Marek Habersack <mhabersack@novell.com> * ISectionSettingsMapper.cs, MembershipSectionMapper.cs, RoleManagerSectionMapper.cs, SettingsMapping.cs, SettingsMappingManager.cs, SettingsMappingWhat.cs: moved to here from System.Web 2008-03-01 Marek Habersack <mhabersack@novell.com> * Mono.Web.dll.sources: added * Makefile: added svn path=/trunk/mcs/; revision=97035
Diffstat (limited to 'mcs/class/Mono.Web')
-rw-r--r--mcs/class/Mono.Web/Assembly/AssemblyInfo.cs60
-rw-r--r--mcs/class/Mono.Web/Assembly/ChangeLog4
-rw-r--r--mcs/class/Mono.Web/ChangeLog6
-rw-r--r--mcs/class/Mono.Web/Makefile14
-rw-r--r--mcs/class/Mono.Web/Mono.Web.Util/ChangeLog7
-rw-r--r--mcs/class/Mono.Web/Mono.Web.Util/ISectionSettingsMapper.cs41
-rw-r--r--mcs/class/Mono.Web/Mono.Web.Util/MembershipSectionMapper.cs165
-rw-r--r--mcs/class/Mono.Web/Mono.Web.Util/RoleManagerSectionMapper.cs165
-rw-r--r--mcs/class/Mono.Web/Mono.Web.Util/SettingsMapping.cs112
-rw-r--r--mcs/class/Mono.Web/Mono.Web.Util/SettingsMappingManager.cs182
-rw-r--r--mcs/class/Mono.Web/Mono.Web.Util/SettingsMappingWhat.cs117
-rw-r--r--mcs/class/Mono.Web/Mono.Web.dll.sources10
12 files changed, 883 insertions, 0 deletions
diff --git a/mcs/class/Mono.Web/Assembly/AssemblyInfo.cs b/mcs/class/Mono.Web/Assembly/AssemblyInfo.cs
new file mode 100644
index 00000000000..ce76bd34222
--- /dev/null
+++ b/mcs/class/Mono.Web/Assembly/AssemblyInfo.cs
@@ -0,0 +1,60 @@
+//
+// AssemblyInfo.cs
+//
+// Author:
+// Marek Habersack (mhabersack@novell.com)
+//
+// (C) 2008 Novell, Inc (http://novell.com/)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Web.UI;
+
+// General Information about the System.Web assembly
+
+[assembly: AssemblyVersion (Consts.FxVersion)]
+[assembly: SatelliteContractVersion (Consts.FxVersion)]
+
+[assembly: AssemblyTitle("Mono.Web.dll")]
+[assembly: AssemblyDescription("Mono.Web.dll")]
+[assembly: AssemblyConfiguration("Development version")]
+[assembly: AssemblyCompany("MONO development team")]
+[assembly: AssemblyProduct("MONO CLI")]
+[assembly: AssemblyCopyright("(c) 2008 Various Authors")]
+[assembly: AssemblyTrademark("")]
+[assembly: CLSCompliant(false)]
+[assembly: ComVisible(false)]
+[assembly: AssemblyDefaultAlias("Mono.Web.dll")]
+[assembly: AssemblyInformationalVersion("0.0.0.1")]
+[assembly: NeutralResourcesLanguage("en-US")]
+
+[assembly: AllowPartiallyTrustedCallers()]
+[assembly: TagPrefix("System.Web.UI.WebControls", "asp")]
+[assembly: AssemblyDelaySign(true)]
+[assembly: AssemblyKeyFile("../msfinal.pub")]
diff --git a/mcs/class/Mono.Web/Assembly/ChangeLog b/mcs/class/Mono.Web/Assembly/ChangeLog
new file mode 100644
index 00000000000..bc992388f54
--- /dev/null
+++ b/mcs/class/Mono.Web/Assembly/ChangeLog
@@ -0,0 +1,4 @@
+2008-03-01 Marek Habersack <mhabersack@novell.com>
+
+ * AssemblyInfo.cs: added
+
diff --git a/mcs/class/Mono.Web/ChangeLog b/mcs/class/Mono.Web/ChangeLog
new file mode 100644
index 00000000000..e426af0a22c
--- /dev/null
+++ b/mcs/class/Mono.Web/ChangeLog
@@ -0,0 +1,6 @@
+2008-03-01 Marek Habersack <mhabersack@novell.com>
+
+ * Mono.Web.dll.sources: added
+
+ * Makefile: added
+
diff --git a/mcs/class/Mono.Web/Makefile b/mcs/class/Mono.Web/Makefile
new file mode 100644
index 00000000000..e0c9afbda3c
--- /dev/null
+++ b/mcs/class/Mono.Web/Makefile
@@ -0,0 +1,14 @@
+thisdir = class/Mono.Web
+SUBDIRS =
+include ../../build/rules.make
+
+LIBRARY = Mono.Web.dll
+LIB_MCS_FLAGS = -r:$(corlib) \
+ -r:System.dll \
+ -r:System.Xml.dll \
+ -r:System.Web.dll \
+ -r:System.Configuration.dll
+
+NO_TEST = yes
+
+include ../../build/library.make
diff --git a/mcs/class/Mono.Web/Mono.Web.Util/ChangeLog b/mcs/class/Mono.Web/Mono.Web.Util/ChangeLog
new file mode 100644
index 00000000000..13f0bb1fae5
--- /dev/null
+++ b/mcs/class/Mono.Web/Mono.Web.Util/ChangeLog
@@ -0,0 +1,7 @@
+2008-03-01 Marek Habersack <mhabersack@novell.com>
+
+ * ISectionSettingsMapper.cs, MembershipSectionMapper.cs,
+ RoleManagerSectionMapper.cs, SettingsMapping.cs,
+ SettingsMappingManager.cs, SettingsMappingWhat.cs: moved to here
+ from System.Web
+
diff --git a/mcs/class/Mono.Web/Mono.Web.Util/ISectionSettingsMapper.cs b/mcs/class/Mono.Web/Mono.Web.Util/ISectionSettingsMapper.cs
new file mode 100644
index 00000000000..864d8c5fa0e
--- /dev/null
+++ b/mcs/class/Mono.Web/Mono.Web.Util/ISectionSettingsMapper.cs
@@ -0,0 +1,41 @@
+//
+// Mono.Web.Util.ISectionSettingsMapper
+//
+// Authors:
+// Marek Habersack (mhabersack@novell.com)
+//
+// (C) 2007 Novell, Inc
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections.Generic;
+
+namespace Mono.Web.Util
+{
+ public interface ISectionSettingsMapper
+ {
+ object MapSection (object section, List <SettingsMappingWhat> whats);
+ }
+}
+#endif
diff --git a/mcs/class/Mono.Web/Mono.Web.Util/MembershipSectionMapper.cs b/mcs/class/Mono.Web/Mono.Web.Util/MembershipSectionMapper.cs
new file mode 100644
index 00000000000..f1b901a99b5
--- /dev/null
+++ b/mcs/class/Mono.Web/Mono.Web.Util/MembershipSectionMapper.cs
@@ -0,0 +1,165 @@
+//
+// Mono.Web.Util.MembershipSectionMapper
+//
+// Authors:
+// Marek Habersack (mhabersack@novell.com)
+//
+// (C) 2007 Novell, Inc
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Web.Configuration;
+
+namespace Mono.Web.Util
+{
+ internal class MembershipSectionMapper : ISectionSettingsMapper
+ {
+ public object MapSection (object _section, List <SettingsMappingWhat> whats)
+ {
+ MembershipSection section = _section as MembershipSection;
+ if (section == null)
+ return _section;
+
+ List <SettingsMappingWhatContents> contents;
+
+ foreach (SettingsMappingWhat what in whats) {
+ contents = what.Contents;
+ if (contents == null || contents.Count == 0)
+ continue;
+
+ foreach (SettingsMappingWhatContents item in contents) {
+ switch (item.Operation) {
+ case SettingsMappingWhatOperation.Add:
+ ProcessAdd (section, item);
+ break;
+
+ case SettingsMappingWhatOperation.Clear:
+ ProcessClear (section, item);
+ break;
+
+ case SettingsMappingWhatOperation.Replace:
+ ProcessReplace (section, item);
+ break;
+
+ case SettingsMappingWhatOperation.Remove:
+ ProcessRemove (section, item);
+ break;
+ }
+ }
+ }
+
+ return section;
+ }
+
+ bool GetCommonAttributes (SettingsMappingWhatContents how, out string name, out string type)
+ {
+ name = type = null;
+
+ Dictionary <string, string> attrs = how.Attributes;
+
+ if (attrs == null || attrs.Count == 0)
+ return false;
+
+ if (!attrs.TryGetValue ("name", out name))
+ return false;
+
+ if (String.IsNullOrEmpty (name))
+ return false;
+
+ attrs.TryGetValue ("type", out type);
+
+ return true;
+ }
+
+ void SetProviderProperties (SettingsMappingWhatContents how, ProviderSettings prov)
+ {
+ Dictionary <string, string> attrs = how.Attributes;
+ if (attrs == null || attrs.Count == 0)
+ return;
+
+ string key;
+ foreach (KeyValuePair <string, string> kvp in attrs) {
+ key = kvp.Key;
+ if (key == "name")
+ continue;
+ if (key == "type") {
+ prov.Type = kvp.Value;
+ continue;
+ }
+ prov.Parameters [key] = kvp.Value;
+ }
+ }
+
+ void ProcessAdd (MembershipSection section, SettingsMappingWhatContents how)
+ {
+ string name, type;
+ if (!GetCommonAttributes (how, out name, out type))
+ return;
+
+ ProviderSettingsCollection providers = section.Providers;
+ ProviderSettings provider = providers [name];
+ if (provider != null)
+ return;
+
+ ProviderSettings prov = new ProviderSettings (name, type);
+ SetProviderProperties (how, prov);
+
+ providers.Add (prov);
+ }
+
+ void ProcessRemove (MembershipSection section, SettingsMappingWhatContents how)
+ {
+ string name, type;
+ if (!GetCommonAttributes (how, out name, out type))
+ return;
+
+ ProviderSettingsCollection providers = section.Providers;
+ ProviderSettings provider = providers [name];
+ if (provider != null) {
+ if (provider.Type != type)
+ return;
+ providers.Remove (name);
+ }
+ }
+
+ void ProcessClear (MembershipSection section, SettingsMappingWhatContents how)
+ {
+ section.Providers.Clear ();
+ }
+
+ void ProcessReplace (MembershipSection section, SettingsMappingWhatContents how)
+ {
+ string name, type;
+ if (!GetCommonAttributes (how, out name, out type))
+ return;
+
+ ProviderSettings provider = section.Providers [name];
+ if (provider != null)
+ SetProviderProperties (how, provider);
+ }
+ }
+}
+#endif
diff --git a/mcs/class/Mono.Web/Mono.Web.Util/RoleManagerSectionMapper.cs b/mcs/class/Mono.Web/Mono.Web.Util/RoleManagerSectionMapper.cs
new file mode 100644
index 00000000000..a812af2793b
--- /dev/null
+++ b/mcs/class/Mono.Web/Mono.Web.Util/RoleManagerSectionMapper.cs
@@ -0,0 +1,165 @@
+//
+// Mono.Web.Util.RoleManagerSectionMapper
+//
+// Authors:
+// Marek Habersack (mhabersack@novell.com)
+//
+// (C) 2007 Novell, Inc
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Web.Configuration;
+
+namespace Mono.Web.Util
+{
+ internal class RoleManagerSectionMapper : ISectionSettingsMapper
+ {
+ public object MapSection (object _section, List <SettingsMappingWhat> whats)
+ {
+ RoleManagerSection section = _section as RoleManagerSection;
+ if (section == null)
+ return _section;
+
+ List <SettingsMappingWhatContents> contents;
+
+ foreach (SettingsMappingWhat what in whats) {
+ contents = what.Contents;
+ if (contents == null || contents.Count == 0)
+ continue;
+
+ foreach (SettingsMappingWhatContents item in contents) {
+ switch (item.Operation) {
+ case SettingsMappingWhatOperation.Add:
+ ProcessAdd (section, item);
+ break;
+
+ case SettingsMappingWhatOperation.Clear:
+ ProcessClear (section, item);
+ break;
+
+ case SettingsMappingWhatOperation.Replace:
+ ProcessReplace (section, item);
+ break;
+
+ case SettingsMappingWhatOperation.Remove:
+ ProcessRemove (section, item);
+ break;
+ }
+ }
+ }
+
+ return section;
+ }
+
+ bool GetCommonAttributes (SettingsMappingWhatContents how, out string name, out string type)
+ {
+ name = type = null;
+
+ Dictionary <string, string> attrs = how.Attributes;
+
+ if (attrs == null || attrs.Count == 0)
+ return false;
+
+ if (!attrs.TryGetValue ("name", out name))
+ return false;
+
+ if (String.IsNullOrEmpty (name))
+ return false;
+
+ attrs.TryGetValue ("type", out type);
+
+ return true;
+ }
+
+ void SetProviderProperties (SettingsMappingWhatContents how, ProviderSettings prov)
+ {
+ Dictionary <string, string> attrs = how.Attributes;
+ if (attrs == null || attrs.Count == 0)
+ return;
+
+ string key;
+ foreach (KeyValuePair <string, string> kvp in attrs) {
+ key = kvp.Key;
+ if (key == "name")
+ continue;
+ if (key == "type") {
+ prov.Type = kvp.Value;
+ continue;
+ }
+ prov.Parameters [key] = kvp.Value;
+ }
+ }
+
+ void ProcessAdd (RoleManagerSection section, SettingsMappingWhatContents how)
+ {
+ string name, type;
+ if (!GetCommonAttributes (how, out name, out type))
+ return;
+
+ ProviderSettingsCollection providers = section.Providers;
+ ProviderSettings provider = providers [name];
+ if (provider != null)
+ return;
+
+ ProviderSettings prov = new ProviderSettings (name, type);
+ SetProviderProperties (how, prov);
+
+ providers.Add (prov);
+ }
+
+ void ProcessRemove (RoleManagerSection section, SettingsMappingWhatContents how)
+ {
+ string name, type;
+ if (!GetCommonAttributes (how, out name, out type))
+ return;
+
+ ProviderSettingsCollection providers = section.Providers;
+ ProviderSettings provider = providers [name];
+ if (provider != null) {
+ if (provider.Type != type)
+ return;
+ providers.Remove (name);
+ }
+ }
+
+ void ProcessClear (RoleManagerSection section, SettingsMappingWhatContents how)
+ {
+ section.Providers.Clear ();
+ }
+
+ void ProcessReplace (RoleManagerSection section, SettingsMappingWhatContents how)
+ {
+ string name, type;
+ if (!GetCommonAttributes (how, out name, out type))
+ return;
+
+ ProviderSettings provider = section.Providers [name];
+ if (provider != null)
+ SetProviderProperties (how, provider);
+ }
+ }
+}
+#endif
diff --git a/mcs/class/Mono.Web/Mono.Web.Util/SettingsMapping.cs b/mcs/class/Mono.Web/Mono.Web.Util/SettingsMapping.cs
new file mode 100644
index 00000000000..bf7431d71e0
--- /dev/null
+++ b/mcs/class/Mono.Web/Mono.Web.Util/SettingsMapping.cs
@@ -0,0 +1,112 @@
+//
+// Mono.Web.Util.SettingsMapping
+//
+// Authors:
+// Marek Habersack (mhabersack@novell.com)
+//
+// (C) 2007 Novell, Inc
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Xml;
+using System.Xml.XPath;
+
+namespace Mono.Web.Util
+{
+ public enum SettingsMappingPlatform
+ {
+ Windows,
+ Unix
+ };
+
+ internal class SettingsMapping
+ {
+ string _sectionTypeName;
+ Type _sectionType;
+ string _mapperTypeName;
+ Type _mapperType;
+ SettingsMappingPlatform _platform;
+ List <SettingsMappingWhat> _whats;
+
+ public Type SectionType {
+ get {
+ if (_sectionType == null)
+ _sectionType = Type.GetType (_sectionTypeName, false);
+ return _sectionType;
+ }
+ }
+
+ public Type MapperType {
+ get {
+ if (_mapperType == null) {
+ _mapperType = Type.GetType (_mapperTypeName, true);
+ if (!typeof (ISectionSettingsMapper).IsAssignableFrom (_mapperType)) {
+ _mapperType = null;
+ throw new InvalidOperationException ("Mapper type does not implement the ISectionSettingsMapper interface");
+ }
+ }
+
+ return _mapperType;
+ }
+ }
+
+ public SettingsMappingPlatform Platform {
+ get { return _platform; }
+ }
+
+ public SettingsMapping (XPathNavigator nav)
+ {
+ _sectionTypeName = nav.GetAttribute ("sectionType", String.Empty);
+ _mapperTypeName = nav.GetAttribute ("mapperType", String.Empty);
+
+ EnumConverter cvt = new EnumConverter (typeof (SettingsMappingPlatform));
+ _platform = (SettingsMappingPlatform) cvt.ConvertFromInvariantString (nav.GetAttribute ("platform", String.Empty));
+
+ LoadContents (nav);
+ }
+
+ public object MapSection (object input, Type type)
+ {
+ if (type != SectionType)
+ throw new ArgumentException ("type", "Invalid section type for this mapper");
+
+ ISectionSettingsMapper mapper = Activator.CreateInstance (MapperType) as ISectionSettingsMapper;
+ if (mapper == null)
+ return input;
+
+ return mapper.MapSection (input, _whats);
+ }
+
+ void LoadContents (XPathNavigator nav)
+ {
+ XPathNodeIterator iter = nav.Select ("./what[string-length (@value) > 0]");
+ _whats = new List <SettingsMappingWhat> ();
+ while (iter.MoveNext ())
+ _whats.Add (new SettingsMappingWhat (iter.Current));
+ }
+ }
+}
+#endif
diff --git a/mcs/class/Mono.Web/Mono.Web.Util/SettingsMappingManager.cs b/mcs/class/Mono.Web/Mono.Web.Util/SettingsMappingManager.cs
new file mode 100644
index 00000000000..9d28d87c618
--- /dev/null
+++ b/mcs/class/Mono.Web/Mono.Web.Util/SettingsMappingManager.cs
@@ -0,0 +1,182 @@
+//
+// Mono.Web.Util.SettingsMappingManager
+//
+// Authors:
+// Marek Habersack (mhabersack@novell.com)
+//
+// (C) 2007 Novell, Inc
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Web;
+using System.Web.Configuration;
+using System.Xml;
+using System.Xml.XPath;
+
+namespace Mono.Web.Util
+{
+ public class SettingsMappingManager
+ {
+ const string settingsMapFileName = "settings.map";
+ const string localSettingsMapFileName = settingsMapFileName + ".config";
+
+ static SettingsMappingManager _instance;
+ static string _mappingFile;
+ Dictionary <Type, SettingsMapping> _mappers;
+ static Dictionary <object, object> _mappedSections;
+ static SettingsMappingPlatform _myPlatform;
+
+ static bool _runningOnWindows;
+ internal static bool IsRunningOnWindows {
+ get { return _runningOnWindows; }
+ }
+
+ public static SettingsMappingPlatform Platform {
+ get { return _myPlatform; }
+ }
+
+ public bool HasMappings {
+ get { return (_mappers != null && _mappers.Count > 0); }
+ }
+
+ static SettingsMappingManager ()
+ {
+ _mappingFile = Path.Combine (Path.GetDirectoryName (RuntimeEnvironment.SystemConfigurationFile), settingsMapFileName);
+ PlatformID pid = Environment.OSVersion.Platform;
+ _runningOnWindows = ((int) pid != 128 && (int) pid != 4);
+
+ }
+
+ static public void Init ()
+ {
+ if (_instance != null)
+ return;
+
+ if (Environment.GetEnvironmentVariable ("MONO_ASPNET_INHIBIT_SETTINGSMAP") != null)
+ return;
+
+ NameValueCollection appSettings = WebConfigurationManager.AppSettings;
+ if (appSettings != null) {
+ string inhibit = appSettings ["MonoAspnetInhibitSettingsMap"];
+ if (String.Compare (inhibit, "true", StringComparison.OrdinalIgnoreCase) == 0)
+ return;
+ }
+
+ if (IsRunningOnWindows)
+ _myPlatform = SettingsMappingPlatform.Windows;
+ else
+ _myPlatform = SettingsMappingPlatform.Unix;
+
+ SettingsMappingManager mapper = new SettingsMappingManager ();
+ mapper.LoadMappings ();
+
+ if (mapper.HasMappings) {
+ _instance = mapper;
+ _mappedSections = new Dictionary <object, object> ();
+ }
+ }
+
+ void LoadMappings ()
+ {
+ if (File.Exists (_mappingFile))
+ LoadMappings (_mappingFile);
+
+ AppDomainSetup domain = AppDomain.CurrentDomain.SetupInformation;
+ string appMappingFile = Path.Combine (domain.ApplicationBase, localSettingsMapFileName);
+ if (File.Exists (appMappingFile))
+ LoadMappings (appMappingFile);
+ }
+
+ void LoadMappings (string mappingFilePath)
+ {
+ XPathNavigator top;
+ XPathDocument doc;
+ try {
+ doc = new XPathDocument (mappingFilePath);
+ top = doc.CreateNavigator ();
+ } catch (Exception ex) {
+ throw new ApplicationException ("Error loading mapping settings", ex);
+ }
+
+ XPathNodeIterator iter;
+ if (_mappers == null)
+ _mappers = new Dictionary <Type, SettingsMapping> ();
+ else {
+ iter = top.Select ("//settingsMap/clear");
+ if (iter.MoveNext ())
+ _mappers.Clear ();
+ }
+
+ iter = top.Select ("//settingsMap/map[string-length (@sectionType) > 0 and string-length (@mapperType) > 0 and string-length (@platform) > 0]");
+ SettingsMapping map;
+
+ while (iter.MoveNext ()) {
+ map = new SettingsMapping (iter.Current);
+ if (_myPlatform != map.Platform)
+ continue;
+
+ if (!_mappers.ContainsKey (map.SectionType))
+ _mappers.Add (map.SectionType, map);
+ else
+ _mappers [map.SectionType] = map;
+ }
+ }
+
+ public static object MapSection (object input)
+ {
+ if (_instance == null || input == null)
+ return input;
+
+ object mappedSection;
+ if (_mappedSections.TryGetValue (input, out mappedSection))
+ return mappedSection;
+
+ object ret = _instance.MapSection (input, input.GetType ());
+ if (ret != null && !_mappedSections.ContainsKey (ret))
+ _mappedSections.Add (ret, ret);
+
+ return ret;
+ }
+
+ object MapSection (object input, Type type)
+ {
+ if (_mappers == null || _mappers.Count == 0 || !_mappers.ContainsKey (type))
+ return input;
+
+ SettingsMapping map;
+ if (!_mappers.TryGetValue (type, out map))
+ return input;
+
+ if (map == null)
+ return input;
+
+ return map.MapSection (input, type);
+ }
+ }
+}
+#endif
diff --git a/mcs/class/Mono.Web/Mono.Web.Util/SettingsMappingWhat.cs b/mcs/class/Mono.Web/Mono.Web.Util/SettingsMappingWhat.cs
new file mode 100644
index 00000000000..94715536a56
--- /dev/null
+++ b/mcs/class/Mono.Web/Mono.Web.Util/SettingsMappingWhat.cs
@@ -0,0 +1,117 @@
+//
+// Mono.Web.Util.SettingsMappingWhat
+//
+// Authors:
+// Marek Habersack (mhabersack@novell.com)
+//
+// (C) 2007 Novell, Inc
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System;
+using System.Collections.Generic;
+using System.Xml;
+using System.Xml.XPath;
+
+namespace Mono.Web.Util
+{
+ public enum SettingsMappingWhatOperation
+ {
+ Add,
+ Clear,
+ Replace,
+ Remove
+ }
+
+ public class SettingsMappingWhatContents
+ {
+ SettingsMappingWhatOperation _operation;
+ Dictionary <string, string> _attributes = new Dictionary <string, string> ();
+
+ public SettingsMappingWhatOperation Operation {
+ get { return _operation; }
+ }
+
+ public Dictionary <string, string> Attributes {
+ get { return _attributes; }
+ }
+
+ public SettingsMappingWhatContents (XPathNavigator nav, SettingsMappingWhatOperation operation)
+ {
+ _operation = operation;
+
+ if (nav.HasAttributes) {
+ nav.MoveToFirstAttribute ();
+ _attributes.Add (nav.Name, nav.Value);
+
+ while (nav.MoveToNextAttribute ())
+ _attributes.Add (nav.Name, nav.Value);
+ }
+ }
+ }
+
+ public class SettingsMappingWhat
+ {
+ string _value;
+ List <SettingsMappingWhatContents> _contents;
+
+ public string Value {
+ get { return _value; }
+ }
+
+ public List <SettingsMappingWhatContents> Contents {
+ get { return _contents; }
+ }
+
+ public SettingsMappingWhat (XPathNavigator nav)
+ {
+ _value = nav.GetAttribute ("value", String.Empty);
+
+ XPathNodeIterator iter = nav.Select ("./*");
+ XPathNavigator cur;
+
+ _contents = new List <SettingsMappingWhatContents> ();
+ while (iter.MoveNext ()) {
+ cur = iter.Current;
+ switch (cur.LocalName) {
+ case "replace":
+ _contents.Add (new SettingsMappingWhatContents (cur, SettingsMappingWhatOperation.Replace));
+ break;
+
+ case "add":
+ _contents.Add (new SettingsMappingWhatContents (cur, SettingsMappingWhatOperation.Add));
+ break;
+
+ case "clear":
+ _contents.Add (new SettingsMappingWhatContents (cur, SettingsMappingWhatOperation.Clear));
+ break;
+
+ case "remove":
+ _contents.Add (new SettingsMappingWhatContents (cur, SettingsMappingWhatOperation.Remove));
+ break;
+ }
+ }
+ }
+ }
+}
+#endif
diff --git a/mcs/class/Mono.Web/Mono.Web.dll.sources b/mcs/class/Mono.Web/Mono.Web.dll.sources
new file mode 100644
index 00000000000..93e66600122
--- /dev/null
+++ b/mcs/class/Mono.Web/Mono.Web.dll.sources
@@ -0,0 +1,10 @@
+Assembly/AssemblyInfo.cs
+../../build/common/Consts.cs
+../../build/common/Locale.cs
+../../build/common/MonoTODOAttribute.cs
+Mono.Web.Util/ISectionSettingsMapper.cs
+Mono.Web.Util/MembershipSectionMapper.cs
+Mono.Web.Util/RoleManagerSectionMapper.cs
+Mono.Web.Util/SettingsMapping.cs
+Mono.Web.Util/SettingsMappingManager.cs
+Mono.Web.Util/SettingsMappingWhat.cs