Profile 详解之 ProfileBase 基类探讨
来源:互联网 发布:linux下安装psutil 编辑:程序博客网 时间:2024/06/08 16:47
2010-03-02 13:17 by ╭☆涩 轨ら, 149 visits, 网摘,收藏,编辑
为什么博文的取名为 ProfileBase 基类呢?ProfileBase 又是作为谁的父类呢?
事实上,这一篇博文将谈到三个类,
也即是 Profile 类, ProfileCommon 类, ProfileBase 类,
其中 Profile 类和 ProfileCommon 类都是派生自 ProfileBase 类,
所以文章的标题取名为 ProfileBase 基类。
上面说到 Profile 类和 ProfileCommon 类都是派生自 ProfileBase 类,
而事实上呢,Profile 类实质上就是一个 ProfileCommon 类(等下解释),
而 ProfileCommon 则是继承自 ProfileBase 类,
故才说 Profile 类和 ProfileCommon 类都是继承自 ProfileBase 基类,
经过了前面几篇博文中 Demo 的介绍,或多或少的也接触到了 ProfileCommon 类,
我想大家也差不多知道这个类大体是干什么用的了,
这个 ProfileCommon 类呢,
其大体的作用就是针对每一个特定的用户的 Profile 进行操作,
前面曾如下使用过
//首先是要实例化一个动态生成的类 ProfileCommon
//这个类代表了一个用户的 Profile
ProfileCommon userCommon =
Profile.GetProfile(ddlUserName.SelectedValue);
lblUser.Text = userCommon.UserName;
lblAddress.Text = userCommon.住址;
lblConstellate.Text = userCommon.星座;
从中可以看出我们先是通过一个 GetProfile() 的方法,
并且传入一个用户名得到的 ProfileCommon 类,
这里就可以知道这个 ProfileCommon 类是针对特定的用户来实例化的,
而后面的使用 ProfileCommon 来访问属性呢也可以表明其是操作单一用户的 Profile ,
同时经过了前面使用 Profile 类的使用,我们也大体知道,
要使用 Profile 这个类的话,我们必须登录成功后才能够使用(先不考虑匿名)
因为您必须告诉 Profile 这个类当前的用户是谁,
这样 Profile . Sava()才能够成功的保存,
不然其将不知道这些用户设置文件要给谁保存,
但是如果您登录成功了的话,
Profile类则会获取当前页面上的用户名(登录成功)来保存用户设置文件,
这样的话,Profile 是针对当前的登录成功的页面上的用户,
而 ProfileCommon 则是针对所有的用户,
但是一个 ProfileCommon 实例只对应一个用户,
从特殊性上看的话,Profile 是比 ProfileCommon 更加特殊的类了,
所以在这里也就不难理解为什么 Profile 实质上就是一个 ProfileCommon 类了,
但是上面的内容还不足以完全证明 Profile 就是一个 ProfileCommon 类,
而且由于 Profile 和 ProfileCommon 两个类都是动态生成的,MSDN 也查不了,
所以更不好证明,
但是下面可以使用调试来完成这个任务,
您可以在 Profile . [ 属性名 ] 上来设置断点,这样就可以查看 Profile 的一些类型信息了,
再启动调试,当运行到断点处时,
由于在这里无法截图(一失去焦点便看不见这些信息了),
所以大家必须自行尝试,但是我还是将一些信息给拷贝过来了的,
比如
Profile = {ProfileCommon}
base {System.Web.Profile.ProfileBase} = {ProfileCommon}
从这里边可以看出 Profile 的类型实质上就是一个 ProfileCommon ,
而 ProfileCommon 则是继承自 ProfileBase 类。
至于 ProfileCommon 继承自 ProfileBase 类的话,
您查 MSDN 也是可以查到的,不过前面的那一条您是差不到的!!!
下面是 MSDN 的说法
ASP.NET 使用 ProfileBase 类创建用于用户配置文件的类。
在启动启用了用户配置文件的应用程序时,
ASP.NET 会创建一个类型为 ProfileCommon 的新类,
该类从 ProfileBase 类继承。
强类型访问器被添加到 profile 配置节中为每个属性定义的 ProfileCommon 类中。
ProfileCommon 类的强类型访问器
调用 ProfileBase 基类的 GetPropertyValue 和SetPropertyValue 方法,
分别用于配置文件属性值的检索和设置。
ProfileCommon 类的一个实例被设置为 ASP.NET 应用程序的 Profile 属性的值。
在上面说了那么多,说实在的也不容易,只是希望各位真的能够理解各种机制,
而不是只会用而已。
这样,证明完 Profile 类就是一个 ProfileCommon 类,
而 ProfileCommon 类又是继承自 ProfileBase 类后,
下面就该介绍一下基类 ProfileBase 类了,
对于这个类的话,我想 MSDN 上面也说得够清楚了,
在这里我就只拷贝点方法过来算了,
大家可以自行去查阅更加详细的资料!!!
来自 MSDN
ProfileBase 类型公开了以下方法。
方法
Create
已重载。 创建用户配置文件的实例。
Equals
确定指定的 Object 是否等于当前的 Object。 (继承自 Object。)
Finalize
允许 Object 在“垃圾回收”回收 Object 之前尝试释放资源并执行其他清理操作。
- (继承自 Object。)
GetHashCode
用作特定类型的哈希函数。 (继承自 Object。)
GetProfileGroup
获取按组名标识的属性组。
GetPropertyValue
获取配置文件属性的值。
GetType
获取当前实例的 Type。 (继承自 Object。)
Initialize
已重载。 初始化当前用户的配置文件属性值和信息。
MemberwiseClone
创建当前 Object 的浅表副本。 (继承自 Object。)
Save
用已更改的配置文件属性值更新配置文件数据源。
(重写 SettingsBase..::.Save()()()。)
SetPropertyValue
设置配置文件属性的值。
ToString
返回表示当前 Object 的 String。 (继承自 Object。)
那么现在大家就应该能够明白 Profile 类 , ProfileCommon 类 , ProfileBase 类 ,
之间到底是什么关系了,也该明白在什么情况下应该使用哪一个类来完成操作了。
- Profile 详解之 ProfileBase 基类探讨
- 自定义继承自ProfileBase的Profile
- Profile 详解之 ProfileModule 类
- 关于Global.asax,ProfileCommon,ProfileBase,ProfileModule,profile,Profile_MigrateAnonyMous,ProfileMigrateEventArgs
- 关于Global.asax,ProfileCommon,ProfileBase,ProfileModule,profile,Profile_MigrateAnonyMous,ProfileMigrateEventArgs
- Maven之Profile详解
- Profile 详解之匿名用户 Profile 使用
- Oracle之用户Profile详解
- Profile 详解之匿名用户初探
- Profile 详解之 Provider 和 基本用法
- Spring入门实战之Profile详解
- Profile 详解之匿名状态迁移至登录状态
- Profile 详解之增删改查个性化配置文件
- profile参数详解
- Oracle Profile 使用详解
- Oracle Profile 使用详解
- ORACLE Profile使用详解
- Oracle Profile 使用详解
- ABAP算MD5值
- 有关静态成员
- Profile 详解之匿名状态迁移至登录状态
- Profile 详解之匿名用户 Profile 使用
- Profile 详解之匿名用户初探
- Profile 详解之 ProfileBase 基类探讨
- WINCE6 中文显示
- Ubuntu Server中的root用户
- Profile 详解之增删改查个性化配置文件
- 抽象类是否可继承实体类 (concrete class)
- VC++ 的串口通讯
- Profile 详解之 Provider 和 基本用法
- FOR 语句的妙用!讲解2-AD批量给用户添加某个用户组权限
- Profile 在 VS 2008 下之怪异问题求指点