Author: ilya
Date: 2007-03-04 12:09:15 -0500 (Sun, 04 Mar 2007)
New Revision: 73690

Modified:
   
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/ChangeLog
   
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPProfileProvider.cs
   
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPUserProfile.cs
Log:
Integration of javax.portlet.PortletPreferences with SettingsPropertyValue.



Modified: 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/ChangeLog
===================================================================
--- 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/ChangeLog
   2007-03-04 16:46:33 UTC (rev 73689)
+++ 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/ChangeLog
   2007-03-04 17:09:15 UTC (rev 73690)
@@ -1,3 +1,9 @@
+03-04-2007    Ilya Kharmatsky    <ilyak -at- mainsoft.com>
+
+       * WPUserProfile.cs: refactored.
+       * WPProfileProvider.cs: added integration with
+       javax.portal.PortalPreferences API (see Get/SetPropertyValues methods)
+
 03-01-2007    Ilya Kharmatsky    <ilyak -at- mainsoft.com>
 
        * WPUserProfile.cs: added the class which is represents the JSR-168

Modified: 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPProfileProvider.cs
===================================================================
--- 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPProfileProvider.cs
        2007-03-04 16:46:33 UTC (rev 73689)
+++ 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPProfileProvider.cs
        2007-03-04 17:09:15 UTC (rev 73690)
@@ -35,15 +35,24 @@
 using System.Web.Profile;
 using System.Configuration;
 
+using java.util;
+using javax.portlet;
+
 using Mainsoft.Web.Security;
+using vmw.portlet;
 
+
+
 namespace Mainsoft.Web.Profile
 {
     public class WPProfileProvider : ProfileProvider
     {
-        private static readonly string DESCRIPTION = "WebSphere Portal Profile 
Provider";
-        private static readonly string NAME = "WPProfileProvider";
+        internal static readonly string DESCRIPTION = "WebSphere Portal 
Profile Provider";
+        internal static readonly string NAME = "WPProfileProvider";
 
+        private static readonly string BIN_SERIALIZATION_PREFIX = 
"VMW_BIN_PREFIX:";
+        private static readonly string BIN_SERIALIZATION_NULL = "#_NULL_#";
+
         private string _applicationName = String.Empty;
 
         public override void Initialize(string name, NameValueCollection 
config)
@@ -84,14 +93,158 @@
             }
         }
 
-        public override SettingsPropertyValueCollection 
GetPropertyValues(SettingsContext context, SettingsPropertyCollection 
collection)
+        public override SettingsPropertyValueCollection 
GetPropertyValues(SettingsContext context, SettingsPropertyCollection 
properties)
         {
-            throw new NotImplementedException("The method or operation is not 
implemented.");
+            
+            SettingsPropertyValueCollection settings = new 
SettingsPropertyValueCollection();
+            PortletRequest pr = null;
+            if (properties.Count == 0)
+                return settings;
+
+            PortletPreferences pp = PortletPreferences;
+            if (pp == null)
+            {
+#if DEBUG
+                Console.WriteLine("Cannot obtain PortletPreferences");
+#endif
+                return settings;
+            }
+            if (!IsInActionPhase)
+            {
+//                throw new ApplicationException("The portlet is not in the 
process action phase");
+                pr = PortletUtils.getPortletRequest();
+                if (pr != null)
+                {
+                    SettingsPropertyValueCollection storedValues = 
+                        
(SettingsPropertyValueCollection)pr.getAttribute("VMW_PROPERTY_VALUES");
+                    if (storedValues != null)
+                        return storedValues;
+                }
+                return settings;
+            }
+
+            foreach (SettingsProperty property in properties)
+            {
+                if (property.SerializeAs == 
SettingsSerializeAs.ProviderSpecific)
+                    if (property.PropertyType.IsPrimitive || 
property.PropertyType == typeof(string))
+                        property.SerializeAs = SettingsSerializeAs.String;
+                    else
+                        property.SerializeAs = SettingsSerializeAs.Xml;
+
+                settings.Add(new SettingsPropertyValue(property));
+            }
+
+            Map portletPreferencesMap = pp.getMap();
+            for (Iterator iter = portletPreferencesMap.keySet().iterator(); 
iter.hasNext(); )
+            {
+                string name = (string)iter.next();
+                string value = (string)portletPreferencesMap.get(name);
+
+                SettingsPropertyValue property = settings[name];
+                
+                if (property == null)
+                    continue;
+
+                if (value == null)
+                {
+                    property.IsDirty = false;
+                    property.Deserialized = true;
+                    property.PropertyValue = null;
+                }
+                else if (value.StartsWith(BIN_SERIALIZATION_PREFIX))
+                {
+                    if (value.StartsWith(BIN_SERIALIZATION_PREFIX + 
BIN_SERIALIZATION_NULL))
+                    {
+                        property.SerializedValue = null;
+                    }
+                    else
+                    {
+                        string base64 = 
value.Substring(BIN_SERIALIZATION_PREFIX.Length);
+                        byte[] serializedData = 
Convert.FromBase64String(base64);
+                        property.SerializedValue = serializedData;
+                    }
+                }
+                else
+                {
+                    property.SerializedValue = value;
+                }
+            }
+
+            pr = (pr == null) ? PortletUtils.getPortletRequest() : pr;
+            if (pr != null)
+            {
+                pr.setAttribute("VMW_PROPERTY_VALUES", settings);
+            }
+            return settings;
+
         }
 
         public override void SetPropertyValues(SettingsContext context, 
SettingsPropertyValueCollection collection)
         {
-            throw new NotImplementedException("The method or operation is not 
implemented.");
+            PortletPreferences pp = PortletPreferences;
+            if (pp == null)
+            {
+#if DEBUG
+                Console.WriteLine("Cannot obtain PortletPreferences");
+#endif
+                return;
+            }
+            if (!IsInActionPhase)
+            {
+#if DEBUG
+                Console.WriteLine("The portlet not in the process action 
phace");
+#endif
+                throw new ApplicationException("The portlet is not in the 
process action phase");
+            }
+            try
+            {
+                string username = (string)context["UserName"];
+                bool authenticated = (bool)context["IsAuthenticated"];
+#if DEBUG
+                Console.WriteLine("The username is : " + username + " and he 
is authenticated: " + authenticated);
+#endif
+                foreach (SettingsPropertyValue spv in collection)
+                {
+                    if (!authenticated && 
!(bool)spv.Property.Attributes["AllowAnonymous"])
+                        continue;
+
+                    if (!spv.IsDirty && spv.UsingDefaultValue)
+                        continue;
+
+                    
+                    string storeValue = null;
+
+                    if (spv.Deserialized && spv.PropertyValue == null)
+                    {
+                        pp.setValue(spv.Name, null);
+                        continue;
+                    }
+
+                    object serialized = spv.SerializedValue;
+                    if (serialized == null)
+                    {
+                        pp.setValue(spv.Name, BIN_SERIALIZATION_PREFIX + 
BIN_SERIALIZATION_NULL);
+                        continue;
+                    }
+                    
+                    if (serialized is string)
+                    {
+                        storeValue = (string)serialized;
+                    }
+                    else
+                    {
+                        string encodedValue = 
Convert.ToBase64String((byte[])serialized);
+                        storeValue = BIN_SERIALIZATION_PREFIX + encodedValue;
+                    }
+                    
+                    pp.setValue(spv.Name, storeValue);
+
+                }
+            }
+            finally
+            {
+                pp.store();
+            }
         }
 
         #region Not Implemented Methods
@@ -144,6 +297,30 @@
             throw new NotImplementedException("The method or operation is not 
implemented.");
         }
         #endregion
+
+        #region Helper Methods
+
+        private PortletPreferences PortletPreferences
+        {
+            get
+            {
+                PortletRequest pr = PortletUtils.getPortletRequest();
+                if (pr == null)
+                    return null;
+                return pr.getPreferences();
+            }
+        }
+
+        private bool IsInActionPhase
+        {
+            get
+            {
+                PortletRequest pr = PortletUtils.getPortletRequest();
+                return pr is ActionRequest;
+            }
+        }
+
+        #endregion
     }
 }
 

Modified: 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPUserProfile.cs
===================================================================
--- 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPUserProfile.cs
    2007-03-04 16:46:33 UTC (rev 73689)
+++ 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPUserProfile.cs
    2007-03-04 17:09:15 UTC (rev 73690)
@@ -30,6 +30,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.Web.Profile;
 using System.Text;
 
 using java.util;
@@ -39,7 +40,7 @@
 
 namespace Mainsoft.Web.Profile
 {
-    public class WPUserProfile
+    public class WPUserProfile : ProfileBase
     {
         private WPUser _user;
 
@@ -48,7 +49,7 @@
             _user = new WPUser();
         }
 
-        public WPUser user
+        public virtual WPUser user
         {
             get { return _user; }
         }
@@ -94,32 +95,32 @@
             return (string)userInfo.get(attribName);
         }
 
-        public string bdate
+        public virtual string bdate
         {
             get { return GetValue("user.bdate"); }
         }
 
-        public string gender
+        public virtual string gender
         {
             get { return GetValue("user.gender"); }
         }
 
-        public string employer
+        public virtual string employer
         {
             get { return GetValue("user.employer"); }
         }
 
-        public string department
+        public virtual string department
         {
             get { return GetValue("user.department"); }
         }
 
-        public string jobtitle
+        public virtual string jobtitle
         {
             get { return GetValue("user.jobtitle"); }
         }
 
-        public UserName name
+        public virtual UserName name
         {
             get { return _name; }
         }
@@ -129,7 +130,7 @@
         /// .Net doesn't allow usage of '-' character in names of properties, 
we are replacing
         /// it with '_'
         /// </summary>
-        public HomeInfo home_info
+        public virtual HomeInfo home_info
         {
             get { return _homeInfo; }
         }
@@ -139,7 +140,7 @@
         /// .Net doesn't allow usage of '-' character in names of properties, 
we are replacing
         /// it with '_'
         /// </summary>
-        public BusinessInfo business_info
+        public virtual BusinessInfo business_info
         {
             get { return _businessInfo; }
         }
@@ -147,468 +148,250 @@
         #region user.home-info class
         public class HomeInfo
         {
-            Postal _postal = new Postal();
-            Telecom _telecom = new Telecom();
-            Online _online = new Online();
+            Postal _postal = new Postal("user.home-info.postal.");
+            Telecom _telecom = new Telecom("user.home-info.telecom.");
+            Online _online = new Online("user.home-info.online.");
 
-            public Postal postal
+            public virtual Postal postal
             {
                 get { return _postal; }
             }
 
-            public Telecom telecom
+            public virtual Telecom telecom
             {
                 get { return _telecom; }
             }
 
-            public Online online
+            public virtual Online online
             {
                 get { return _online; }
             }
+        }
+        #endregion
 
-            #region user.home-info.postal class
-            public class Postal
-            {
-                public string name
-                {
-                    get { return 
WPUser.GetValue("user.home-info.postal.name"); }
-                }
+        #region user.business-info class
+        public class BusinessInfo
+        {
 
-                public string street
-                {
-                    get { return 
WPUser.GetValue("user.home-info.postal.street"); }
-                }
+            Postal _postal = new Postal("user.business-info.postal.");
+            Telecom _telecom = new Telecom("user.business-info.telecom.");
+            Online _online = new Online("user.business-info.online.");
 
-                public string city
-                {
-                    get { return 
WPUser.GetValue("user.home-info.postal.city"); }
-                }
-
-                public string stateprov
-                {
-                    get { return 
WPUser.GetValue("user.home-info.postal.stateprov"); }
-                }
-
-                public string postalcode
-                {
-                    get { return 
WPUser.GetValue("user.home-info.postal.postalcode"); }
-                }
-
-                public string country
-                {
-                    get { return 
WPUser.GetValue("user.home-info.postal.country"); }
-                }
-
-                public string organization
-                {
-                    get { return 
WPUser.GetValue("user.home-info.postal.organization"); }
-                }
+            public virtual Postal postal
+            {
+                get { return _postal; }
             }
-            #endregion
 
-            #region user.home-info.telecom class
-            public class Telecom
+            public virtual Telecom telecom
             {
-                private Telephone _telephone = new Telephone();
-                private Fax _fax = new Fax();
-                private Mobile _mobile = new Mobile();
-                private Pager _pager = new Pager();
-
-                public Telephone telephone 
-                {
-                    get { return _telephone;}
-                }
-
-                public Fax fax 
-                {
-                    get { return _fax;}
-                }
-
-                public Mobile mobile
-                {
-                    get { return _mobile;}
-                }
-
-                public Pager pager 
-                {
-                    get { return _pager;}
-                }
-
-                #region user.home-info.telecom.telephone class
-                public class Telephone 
-                {
-                    public string intcode
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.telephone.intcode");}
-                    }
-                    
-                    public string loccode
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.telephone.loccode");}
-                    }
-                    
-                    public string number
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.telephone.number");}
-                    }
-
-                    public string ext
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.telephone.ext");}
-                    }
-
-                    public string comment
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.telephone.comment");}
-                    }
-                }
-                #endregion
-
-                #region user.home-info.telecom.fax class
-                public class Fax 
-                {
-                    public string intcode
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.fax.intcode");}
-                    }
-                    
-                    public string loccode
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.fax.loccode");}
-                    }
-                    
-                    public string number
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.fax.number");}
-                    }
-
-                    public string ext
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.fax.ext");}
-                    }
-        
-                    public string comment
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.fax.comment");}
-                    }
-                }
-                #endregion
-
-                #region user.home-info.telecom.mobile class
-                public class Mobile 
-                {
-                    public string intcode
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.mobile.intcode");}
-                    }
-                    public string loccode
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.mobile.loccode");}
-                    }
-                    public string number
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.mobile.number");}
-                    }
-                    public string ext
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.mobile.ext");}
-                    }
-                    public string comment
-                    {
-                        get { return 
WPUser.GetValue("user.home-info.telecom.mobile.comment");}
-                    }
-                }
-                #endregion
-
-                #region user.home-info.telecom.pager class
-                public class Pager 
-                {
-                    public string intcode 
-                    {
-                        get {return 
WPUser.GetValue("user.home-info.telecom.pager.intcode");}
-                    }
-
-                    public string loccode 
-                    {
-                        get {return 
WPUser.GetValue("user.home-info.telecom.pager.loccode");}
-                    }
-
-                    public string number 
-                    {
-                        get {return 
WPUser.GetValue("user.home-info.telecom.pager.number");}
-                    }
-
-                    public string ext 
-                    {
-                        get {return 
WPUser.GetValue("user.home-info.telecom.pager.ext");}
-                    }
-
-                    public string comment
-                    {
-                        get {return 
WPUser.GetValue("user.home-info.telecom.pager.comment");}
-                    }
-                }
-                #endregion
+                get { return _telecom; }
             }
-            #endregion
 
-            #region user.home-info.online class
-            public class Online
+            public virtual Online online
             {
-                public string email
-                {
-                    get { return 
WPUser.GetValue("user.home-info.online.email");}
-                }
-
-                public string uri
-                {
-                    get { return WPUser.GetValue("user.home-info.online.uri"); 
}
-                }
+                get { return _online; }
             }
-            #endregion
         }
         #endregion
 
-        #region user.business-info class
-        public class BusinessInfo
+        #region user.name class
+        public class UserName
         {
+            public virtual string prefix
+            {
+                get { return WPUser.GetValue("user.name.prefix"); }
+            }
 
-            Postal _postal = new Postal();
-            Telecom _telecom = new Telecom();
-            Online _online = new Online();
+            public virtual string given
+            {
+                get { return WPUser.GetValue("user.name.given"); }
+            }
 
-            public Postal postal
+            public virtual string family
             {
-                get { return _postal; }
+                get { return WPUser.GetValue("user.name.family"); }
             }
 
-            public Telecom telecom
+            public virtual string middle
             {
-                get { return _telecom; }
+                get { return WPUser.GetValue("user.name.middle"); }
             }
 
-            public Online online
+            public virtual string suffix
             {
-                get { return _online; }
+                get { return WPUser.GetValue("user.name.suffix"); }
             }
 
-            #region user.business-info.postal class
-            public class Postal
+            public virtual string nickName
             {
-                public string name 
-                {
-                    get { return 
WPUser.GetValue("user.business-info.postal.name");}
-                }
-                
-                public string street
-                {
-                    get { return 
WPUser.GetValue("user.business-info.postal.street");}
-                }
+                get { return WPUser.GetValue("user.name.nickName"); }
+            }
+        }
+        #endregion
+    }
+    #endregion
 
-                public string city
-                {
-                    get { return 
WPUser.GetValue("user.business-info.postal.city");}
-                }
-                
-                public string stateprov
-                {
-                    get { return 
WPUser.GetValue("user.business-info.postal.stateprov");}
-                }
-                
-                public string postalcode
-                {
-                    get { return 
WPUser.GetValue("user.business-info.postal.postalcode");}
-                }
-                
-                public string country
-                {
-                    get { return 
WPUser.GetValue("user.business-info.postal.country");}
-                }
+    #region TelecomInfo class (contains telecom devices specific info)
+    public class TelecomInfo
+    {
 
-                public string organization
-                {
-                    get { return 
WPUser.GetValue("user.business-info.postal.organization");}
-                }
+        private string _intcode;
+        private string _loccode;
+        private string _number;
+        private string _ext;
+        private string _comment;
 
-            }
-            #endregion
+        public TelecomInfo(string prefix)
+        {
+            if(prefix == null)
+                throw new ArgumentNullException("prefix");
 
-            #region user.business-info.telecom
-            public class Telecom
-            {
-                private Pager _pager = new Pager();
-                private Telephone _telephone = new Telephone();
-                private Fax _fax = new Fax();
-                private Mobile _mobile = new Mobile();
+            _intcode = prefix + "intcode";
+            _loccode = prefix + "loccode";
+            _number  = prefix + "number";
+            _ext = prefix + "ext";
+            _comment = prefix + "comment";
+        }
 
+        public virtual string intcode
+        {
+            get { return WPUser.GetValue(_intcode); }
+        }
 
-                public Pager pager { get { return _pager; } }
-                public Telephone telephone { get { return _telephone; } }
-                public Fax fax { get { return _fax; } }
-                public Mobile mobile { get { return _mobile; } }
+        public virtual string loccode
+        {
+            get { return WPUser.GetValue(_loccode); }
+        }
 
-                public class Pager
-                {
-                    public string intcode
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.pager.intcode"); }
-                    }
+        public virtual string number
+        {
+            get { return WPUser.GetValue(_number); }
+        }
 
-                    public string loccode
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.pager.loccode"); }
-                    }
+        public virtual string ext
+        {
+            get { return WPUser.GetValue(_ext); }
+        }
 
-                    public string number
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.pager.number"); }
-                    }
+        public virtual string comment
+        {
+            get { return WPUser.GetValue(_comment); }
+        }
+    }
+    #endregion
 
-                    public string ext
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.pager.ext"); }
-                    }
+    #region Postal class (contains ground postal info)
+    public class Postal
+    {
+        
+        private string _name;
+        private string _street;
+        private string _city;
+        private string _stateprov;
+        private string _postalcode;
+        private string _country;
+        private string _organization;
 
-                    public string comment
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.pager.comment"); }
-                    }
-                }
 
-                public class Mobile
-                {
-                    public string intcode
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.mobile.intcode"); }
-                    }
-                    public string loccode
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.mobile.loccode"); }
-                    }
-                    public string number
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.mobile.number"); }
-                    }
-                    public string ext
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.mobile.ext"); }
-                    }
-                    public string comment
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.mobile.comment"); }
-                    }
-                }
+        public Postal(string prefix)
+        {
+            if (prefix == null)
+                throw new ArgumentNullException("prefix");
 
-                public class Telephone
-                {
-                    public string intcode 
-                    {
-                        get {return 
WPUser.GetValue("user.business-info.telecom.telephone.intcode");}
-                    }
+            _name   = prefix + "name";
+            _street = prefix + "street";
+            _city = prefix + "city";
+            _stateprov = prefix + "stateprov";
+            _postalcode = prefix + "postalcode";
+            _country = prefix + "country";
+            _organization = prefix + "organization";
+        }
 
-                    public string loccode 
-                    {
-                        get {return 
WPUser.GetValue("user.business-info.telecom.telephone.loccode");}
-                    }
-                    
-                    public string number
-                    {
-                        get {return 
WPUser.GetValue("user.business-info.telecom.telephone.number");}
-                    }
+        public virtual string name
+        {
+            get { return WPUser.GetValue(_name); }
+        }
 
-                    public string ext
-                    {
-                        get {return 
WPUser.GetValue("user.business-info.telecom.telephone.ext");}
-                    }
+        public virtual string street
+        {
+            get { return WPUser.GetValue(_organization); }
+        }
 
-                    public string comment
-                    {
-                        get {return 
WPUser.GetValue("user.business-info.telecom.telephone.comment");}
-                    }     
-                }
+        public virtual string city
+        {
+            get { return WPUser.GetValue(_city); }
+        }
 
-                public class Fax
-                {
-                    public string intcode
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.fax.intcode"); }
-                    }
+        public virtual string stateprov
+        {
+            get { return WPUser.GetValue(_stateprov); }
+        }
 
-                    public string loccode
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.fax.loccode"); }
-                    }
+        public virtual string postalcode
+        {
+            get { return WPUser.GetValue(_postalcode); }
+        }
 
-                    public string number
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.fax.number"); }
-                    }
+        public virtual string country
+        {
+            get { return WPUser.GetValue(_country); }
+        }
 
-                    public string ext
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.fax.ext"); }
-                    }
+        public virtual string organization
+        {
+            get { return WPUser.GetValue(_organization); }
+        }
 
-                    public string comment
-                    {
-                        get { return 
WPUser.GetValue("user.business-info.telecom.fax.comment"); }
-                    }
-                }
-            }
-            #endregion
+    }
+    #endregion
 
-            #region user.business-info.online
-            public class Online
-            {
-                public string email
-                {
-                    get { return 
WPUser.GetValue("user.business-info.online.email"); }
-                }
+    #region Online class (contains on-line info)
+    public class Online
+    {
+        private string namespacePrefix;
 
-                public string uri
-                {
-                    get { return 
WPUser.GetValue("user.business-info.online.uri"); }
-                }
-            }
-            #endregion
-
+        public Online(string prefix)
+        {
+            namespacePrefix = prefix;
         }
-        #endregion
+        public virtual string email
+        {
+            get { return WPUser.GetValue(namespacePrefix + "email"); }
+        }
 
-        #region user.name class
-        public class UserName
+        public virtual string uri
         {
-            public string prefix
-            {
-                get { return WPUser.GetValue("user.name.prefix"); }
-            }
+            get { return WPUser.GetValue(namespacePrefix + "uri"); }
+        }
+    }
+    #endregion
 
-            public string given
-            {
-                get { return WPUser.GetValue("user.name.given"); }
-            }
+    #region Telecom class (contains telecom info - see TelecomInfo)
+    public class Telecom
+    {
+        private string namespacePrefix;
 
-            public string family
-            {
-                get { return WPUser.GetValue("user.name.family"); }
-            }
 
-            public string middle
-            {
-                get { return WPUser.GetValue("user.name.middle"); }
-            }
 
-            public string suffix
-            {
-                get { return WPUser.GetValue("user.name.suffix"); }
-            }
+        private TelecomInfo _pager;
+        private TelecomInfo _telephone;
+        private TelecomInfo _fax;
+        private TelecomInfo _mobile;
 
-            public string nickName
-            {
-                get { return WPUser.GetValue("user.name.nickName"); }
-            }
+        public Telecom(string prefix)
+        {
+            namespacePrefix = prefix;
+            _pager = new TelecomInfo(namespacePrefix + "pager.");
+            _telephone = new TelecomInfo(namespacePrefix + "telephone.");
+            _fax = new TelecomInfo(namespacePrefix + "fax.");
+            _mobile = new TelecomInfo(namespacePrefix + "mobile.");
         }
-        #endregion
+
+        public virtual TelecomInfo pager { get { return _pager; } }
+        public virtual TelecomInfo telephone { get { return _telephone; } }
+        public virtual TelecomInfo fax { get { return _fax; } }
+        public virtual TelecomInfo mobile { get { return _mobile; } }
+
     }
     #endregion
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to