// 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)
{
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;
}
}
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.");
}
}
-#endif