// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
using System;
using System.Configuration;
using System.Configuration.Provider;
SettingsPropertyValueCollection _propertiyValues = null;
const string Profiles_SettingsPropertyCollection = "Profiles.SettingsPropertyCollection";
-#if TARGET_J2EE
- static SettingsPropertyCollection _properties
- {
- get
- {
- object o = AppDomain.CurrentDomain.GetData (Profiles_SettingsPropertyCollection);
- return (SettingsPropertyCollection) o;
- }
- set
- {
- AppDomain.CurrentDomain.SetData (Profiles_SettingsPropertyCollection, value);
- }
- }
-#else
static SettingsPropertyCollection _properties = null;
-#endif
static void InitProperties ()
{
ProfilePropertySettingsCollection ppsc = pgs.PropertySettings;
for (int s = 0; s < ppsc.Count; s++) {
- SettingsProperty settingsProperty = CreateSettingsPropery (pgs, ppsc [s]);
- ValidateProperty (settingsProperty, ppsc [i].ElementInformation);
+ SettingsProperty settingsProperty = CreateSettingsProperty (pgs, ppsc [s]);
+ ValidateProperty (settingsProperty, ppsc [s].ElementInformation);
properties.Add (settingsProperty);
}
}
for (int s = 0; s < ps.Count; s++) {
- SettingsProperty settingsProperty = CreateSettingsPropery (null, ps [s]);
+ SettingsProperty settingsProperty = CreateSettingsProperty (null, ps [s]);
ValidateProperty (settingsProperty, ps [s].ElementInformation);
properties.Add (settingsProperty);
}
PropertyInfo [] pi = properiesType.GetProperties (BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
if (pi.Length > 0)
for (int i = 0; i < pi.Length; i++)
- properties.Add (CreateSettingsPropery (pi [i]));
+ properties.Add (CreateSettingsProperty (pi [i]));
if (properiesType.BaseType == null ||
properiesType.BaseType == typeof (ProfileBase))
static Type GetPropertyType (ProfileGroupSettings pgs, ProfilePropertySettings pps)
{
- Type type = Type.GetType (pps.Type);
+ Type type = HttpApplication.LoadType (pps.Type);
if (type != null)
return type;
elementInfo.Source, elementInfo.LineNumber);
}
- static SettingsProperty CreateSettingsPropery (PropertyInfo property)
+ static SettingsProperty CreateSettingsProperty (PropertyInfo property)
{
SettingsProperty sp = new SettingsProperty (property.Name);
-
- Attribute [] attributes = (Attribute [])property.GetCustomAttributes (typeof (SettingsSerializeAsAttribute), false);
+ Attribute [] attributes = (Attribute [])property.GetCustomAttributes (false);
SettingsAttributeDictionary attDict = new SettingsAttributeDictionary();
+ bool defaultAssigned = false;
+
sp.SerializeAs = SettingsSerializeAs.ProviderSpecific;
sp.PropertyType = property.PropertyType;
sp.IsReadOnly = false;
sp.ThrowOnErrorSerializing = true;
for (int i = 0; i < attributes.Length; i++) {
- if (attributes [i] is DefaultSettingValueAttribute)
+ if (attributes [i] is DefaultSettingValueAttribute) {
sp.DefaultValue = ((DefaultSettingValueAttribute) attributes [i]).Value;
-
- else if (attributes [i] is SettingsProviderAttribute) {
- Type providerType = Type.GetType (((SettingsProviderAttribute) attributes [i]).ProviderTypeName);
+ defaultAssigned = true;
+ } else if (attributes [i] is SettingsProviderAttribute) {
+ Type providerType = HttpApplication.LoadType (((SettingsProviderAttribute) attributes [i]).ProviderTypeName);
sp.Provider = (SettingsProvider) Activator.CreateInstance (providerType);
sp.Provider.Initialize (null, null);
- }
-
- else if (attributes [i] is SettingsSerializeAsAttribute)
+ } else if (attributes [i] is SettingsSerializeAsAttribute) {
sp.SerializeAs = ((SettingsSerializeAsAttribute) attributes [i]).SerializeAs;
-
- else if (
- attributes [i] is SettingsAllowAnonymousAttribute ||
- attributes [i] is ApplicationScopedSettingAttribute ||
- attributes [i] is UserScopedSettingAttribute ||
- attributes [i] is SettingsDescriptionAttribute ||
- attributes [i] is SettingAttribute)
+ } else if (attributes [i] is SettingsAllowAnonymousAttribute) {
+ sp.Attributes ["AllowAnonymous"] = ((SettingsAllowAnonymousAttribute) attributes [i]).Allow;
+ } else if (attributes [i] is CustomProviderDataAttribute) {
+ sp.Attributes ["CustomProviderData"] = ((CustomProviderDataAttribute) attributes [i]).CustomProviderData;
+ } else if (attributes [i] is ApplicationScopedSettingAttribute ||
+ attributes [i] is UserScopedSettingAttribute ||
+ attributes [i] is SettingsDescriptionAttribute ||
+ attributes [i] is SettingAttribute)
attDict.Add (attributes [i].GetType (), attributes [i]);
}
if (sp.Attributes ["AllowAnonymous"] == null)
sp.Attributes ["AllowAnonymous"] = false;
+ if (!defaultAssigned && sp.PropertyType == typeof (string) && sp.DefaultValue == null)
+ sp.DefaultValue = String.Empty;
+
return sp;
}
- static SettingsProperty CreateSettingsPropery (ProfileGroupSettings pgs, ProfilePropertySettings pps)
+
+ static SettingsProperty CreateSettingsProperty (ProfileGroupSettings pgs, ProfilePropertySettings pps)
{
- string name = ((pgs == null) ? "" : pgs.Name + ".") + pps.Name;
+ string name = ((pgs == null) ? String.Empty : pgs.Name + ".") + pps.Name;
SettingsProperty sp = new SettingsProperty (name);
sp.Attributes.Add ("AllowAnonymous", pps.AllowAnonymous);
}
}
- public static SettingsPropertyCollection Properties {
+ public new static SettingsPropertyCollection Properties {
get {
if (_properties == null)
InitProperties ();
}
-#endif