ProfileService.cs
上传用户:szgaoree
上传日期:2009-01-05
资源大小:74k
文件大小:2k
源码类别:

Ajax

开发平台:

C#

  1. #if(NET20)
  2. /*
  3.  * MS 05-12-20 initial version
  4.  * MS 06-04-16 changed methods to static
  5.  * 
  6.  * 
  7.  * 
  8.  * 
  9.  */
  10. using System;
  11. using System.Collections;
  12. using System.Configuration;
  13. using System.Web;
  14. using System.Web.Profile;
  15. namespace AjaxPro.Services
  16. {
  17. [AjaxNamespace("AjaxPro.Services.Profile")]
  18. public class ProfileService
  19. {
  20.         [AjaxMethod]
  21.         public static Hashtable GetProfile()
  22.         {
  23.             ProfileBase profile = HttpContext.Current.Profile;
  24.             if (profile == null)
  25.             {
  26.                 return null;
  27.             }
  28.             Hashtable ht = new Hashtable();
  29.             foreach(SettingsProperty property in ProfileBase.Properties)
  30.             {
  31.                 ht.Add(property.Name, profile[property.Name]);
  32.             }
  33.             return ht;
  34.         }
  35.         [AjaxMethod]
  36.         public static IDictionary GetProfileProperties(Array properties)
  37.         {
  38.             ProfileBase profile = HttpContext.Current.Profile;
  39.             if (profile == null)
  40.             {
  41.                 return null;
  42.             }
  43.             Hashtable ht = new Hashtable();
  44.             foreach(string name in properties)
  45.             {
  46.                 ht.Add(name, profile[name]);
  47.             }
  48.             return ht;
  49.         }
  50.         [AjaxMethod]
  51.         public static void SetProfile(Hashtable ht)
  52.         {
  53.             ProfileBase profile = HttpContext.Current.Profile;
  54.             foreach (DictionaryEntry entry in ht)
  55.             {
  56.                 profile[(string)entry.Key] = entry.Value;
  57.             }
  58.         }
  59. }
  60. }
  61. #endif