Author: krasnov
Date: 2007-01-02 07:32:40 -0500 (Tue, 02 Jan 2007)
New Revision: 70350
Modified:
trunk/mcs/class/System.Web/System.Web.Profile/ChangeLog
trunk/mcs/class/System.Web/System.Web.Profile/ProfileBase.cs
Log:
* ProfileBase.cs: added inherited properties properties initialization
Modified: trunk/mcs/class/System.Web/System.Web.Profile/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Profile/ChangeLog 2007-01-02
12:13:49 UTC (rev 70349)
+++ trunk/mcs/class/System.Web/System.Web.Profile/ChangeLog 2007-01-02
12:32:40 UTC (rev 70350)
@@ -1,3 +1,7 @@
+2007-01-02 Vladimir Krasnov <[EMAIL PROTECTED]>
+
+ * ProfileBase.cs: added inherited properties properties initialization
+
2006-12-26 Vladimir Krasnov <[EMAIL PROTECTED]>
* ProfileGroupBase.cs: fixed property name while getting from parent
Modified: trunk/mcs/class/System.Web/System.Web.Profile/ProfileBase.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Profile/ProfileBase.cs
2007-01-02 12:13:49 UTC (rev 70349)
+++ trunk/mcs/class/System.Web/System.Web.Profile/ProfileBase.cs
2007-01-02 12:32:40 UTC (rev 70350)
@@ -33,6 +33,7 @@
using System.Configuration.Provider;
using System.Web.Security;
using System.Web.Configuration;
+using System.Reflection;
namespace System.Web.Profile
{
@@ -87,6 +88,25 @@
properties.Add (settingsProperty);
}
+ if (config.Inherits.Length > 0) {
+ Type profileType =
ProfileParser.GetProfileCommonType (HttpContext.Current);
+ if (profileType != null) {
+ Type properiesType =
profileType.BaseType;
+ for (; ; ) {
+ 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]));
+
+ if (properiesType.BaseType ==
null ||
+ properiesType.BaseType
== typeof (ProfileBase))
+ break;
+
+ properiesType =
properiesType.BaseType;
+ }
+ }
+ }
+
properties.SetReadOnly ();
lock (Profiles_SettingsPropertyCollection) {
if (_properties == null)
@@ -188,7 +208,7 @@
if (profileType == null)
return null;
- System.Reflection.PropertyInfo pi =
profileType.GetProperty (pps.Name);
+ PropertyInfo pi = profileType.GetProperty (pps.Name);
if (pi != null)
return pi.PropertyType;
@@ -216,6 +236,48 @@
elementInfo.Source,
elementInfo.LineNumber);
}
+ static SettingsProperty CreateSettingsPropery (PropertyInfo
property)
+ {
+ SettingsProperty sp = new SettingsProperty
(property.Name);
+
+ Attribute [] attributes = (Attribute
[])property.GetCustomAttributes (typeof (SettingsSerializeAsAttribute), false);
+ SettingsAttributeDictionary attDict = new
SettingsAttributeDictionary();
+ sp.SerializeAs = SettingsSerializeAs.ProviderSpecific;
+ sp.PropertyType = property.PropertyType;
+ sp.IsReadOnly = false;
+ sp.ThrowOnErrorDeserializing = false;
+ sp.ThrowOnErrorSerializing = true;
+
+ for (int i = 0; i < attributes.Length; i++) {
+ 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);
+ sp.Provider = (SettingsProvider)
Activator.CreateInstance (providerType);
+ sp.Provider.Initialize (null, null);
+ }
+
+ 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)
+ attDict.Add (attributes [i].GetType (),
attributes [i]);
+ }
+
+ if (sp.Provider == null)
+ sp.Provider = ProfileManager.Provider;
+
+ if (sp.Attributes ["AllowAnonymous"] == null)
+ sp.Attributes ["AllowAnonymous"] = false;
+
+ return sp;
+ }
static SettingsProperty CreateSettingsPropery
(ProfileGroupSettings pgs, ProfilePropertySettings pps)
{
string name = ((pgs == null) ? "" : pgs.Name + ".") +
pps.Name;
@@ -257,6 +319,9 @@
_settingsContext = new SettingsContext ();
_settingsContext.Add ("UserName", username);
_settingsContext.Add ("IsAuthenticated",
isAuthenticated);
+ SettingsProviderCollection spc = new
SettingsProviderCollection();
+ spc.Add (ProfileManager.Provider);
+ base.Initialize (Context, ProfileBase.Properties, spc);
}
public override void Save ()
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches