Merge pull request #1519 from akoeplinger/remove-net35-ifdef
[mono.git] / mcs / class / System.Web / System.Web.Profile / ProfileManager.cs
index 25dda031cb21b08f0a012702fc842c0c865540cf..24d20ed54eaadb4f6ead36fd17f53d32c84ddbf3 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
 using System;
 using System.Web;
 using System.Web.Configuration;
+using System.Configuration;
 
 namespace System.Web.Profile
 {
        public static class ProfileManager
        {
-#if TARGET_J2EE
-               const string Profiles_config = "Profiles.config";
-               const string Profiles_ProfileProviderCollection = "Profiles.ProfileProviderCollection";
-               private static ProfileSection config
-               {
-                       get
-                       {
-                               object o = AppDomain.CurrentDomain.GetData (Profiles_config);
-                               if (o == null) {
-                                       config = (ProfileSection) WebConfigurationManager.GetSection ("system.web/profile");
-                                       return (ProfileSection) config;
-                               }
-
-                               return (ProfileSection) o;
-                       }
-                       set
-                       {
-                               AppDomain.CurrentDomain.SetData (Profiles_config, value);
-                       }
-               }
-               private static ProfileProviderCollection providersCollection
-               {
-                       get
-                       {
-                               object o = AppDomain.CurrentDomain.GetData (Profiles_ProfileProviderCollection);
-                               return (ProfileProviderCollection) o;
-                       }
-                       set
-                       {
-                               AppDomain.CurrentDomain.SetData (Profiles_ProfileProviderCollection, value);
-                       }
-               }
-#else
-               private static ProfileSection config;
-               private static ProfileProviderCollection providersCollection;
+               static ProfileSection config;
+               static ProfileProviderCollection providersCollection;
 
                static ProfileManager ()
                {
                        config = (ProfileSection) WebConfigurationManager.GetSection ("system.web/profile");
                }
-#endif
 
                public static int DeleteInactiveProfiles (ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
                {
@@ -185,7 +151,7 @@ namespace System.Web.Profile
                        get     {
                                ProfileProvider p = Providers [config.DefaultProvider];
                                if (p == null)
-                                       throw new HttpException ("Provider '" + config.DefaultProvider + "' was not found");
+                                       throw new ConfigurationErrorsException ("Provider '" + config.DefaultProvider + "' was not found");
                                return p;
                        }
                }
@@ -194,14 +160,15 @@ namespace System.Web.Profile
                        get {
                                CheckEnabled ();
                                if (providersCollection == null) {
-                                       providersCollection = new ProfileProviderCollection ();
-                                       ProvidersHelper.InstantiateProviders (config.Providers, providersCollection, typeof (ProfileProvider));
+                                       ProfileProviderCollection providersCollectionTmp = new ProfileProviderCollection ();
+                                       ProvidersHelper.InstantiateProviders (config.Providers, providersCollectionTmp, typeof (ProfileProvider));
+                                       providersCollection = providersCollectionTmp;
                                }
                                return providersCollection;
                        }
                }
 
-               private static void CheckEnabled ()
+               static void CheckEnabled ()
                {
                        if (!Enabled)
                                throw new Exception ("This feature is not enabled.  To enable it, add <profile enabled=\"true\"> to your configuration file.");
@@ -210,4 +177,3 @@ namespace System.Web.Profile
        }
 }
 
-#endif