RootProfilePropertySettingsCollection 类

定义

充当集合的两级命名层次结构的 ProfilePropertySettingsCollection 顶部。

public ref class RootProfilePropertySettingsCollection sealed : System::Web::Configuration::ProfilePropertySettingsCollection
[System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.ProfilePropertySettings))]
public sealed class RootProfilePropertySettingsCollection : System.Web.Configuration.ProfilePropertySettingsCollection
[<System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.ProfilePropertySettings))>]
type RootProfilePropertySettingsCollection = class
    inherit ProfilePropertySettingsCollection
Public NotInheritable Class RootProfilePropertySettingsCollection
Inherits ProfilePropertySettingsCollection
继承
属性

示例

下面的代码示例演示如何使用 RootProfilePropertySettingsCollection 类型作为 PropertySettings 类的属性 ProfileSection 。 该代码示例是 ProfileSection 类中的一个较大示例的一部分。


// Display all current root ProfilePropertySettings.
Console.WriteLine("Current Root ProfilePropertySettings:");
int rootPPSCtr = 0;
foreach (ProfilePropertySettings rootPPS in profileSection.PropertySettings)
{
    Console.WriteLine("  {0}: ProfilePropertySetting '{1}'", ++rootPPSCtr,
        rootPPS.Name);
}

// Get and modify a root ProfilePropertySettings object.
Console.WriteLine(
    "Display and modify 'LastReadDate' ProfilePropertySettings:");
ProfilePropertySettings profilePropertySettings =
    profileSection.PropertySettings["LastReadDate"];

// Get the current ReadOnly property value.
Console.WriteLine(
    "Current ReadOnly value: '{0}'", profilePropertySettings.ReadOnly);

// Set the ReadOnly property to true.
profilePropertySettings.ReadOnly = true;

// Get the current AllowAnonymous property value.
Console.WriteLine(
    "Current AllowAnonymous value: '{0}'", profilePropertySettings.AllowAnonymous);

// Set the AllowAnonymous property to true.
profilePropertySettings.AllowAnonymous = true;

// Get the current SerializeAs property value.
Console.WriteLine(
    "Current SerializeAs value: '{0}'", profilePropertySettings.SerializeAs);

// Set the SerializeAs property to SerializationMode.Binary.
profilePropertySettings.SerializeAs = SerializationMode.Binary;

// Get the current Type property value.
Console.WriteLine(
    "Current Type value: '{0}'", profilePropertySettings.Type);

// Set the Type property to "System.DateTime".
profilePropertySettings.Type = "System.DateTime";

// Get the current DefaultValue property value.
Console.WriteLine(
    "Current DefaultValue value: '{0}'", profilePropertySettings.DefaultValue);

// Set the DefaultValue property to "March 16, 2004".
profilePropertySettings.DefaultValue = "March 16, 2004";

// Get the current ProviderName property value.
Console.WriteLine(
    "Current ProviderName value: '{0}'", profilePropertySettings.Provider);

// Set the ProviderName property to "AspNetSqlRoleProvider".
profilePropertySettings.Provider = "AspNetSqlRoleProvider";

// Get the current Name property value.
Console.WriteLine(
    "Current Name value: '{0}'", profilePropertySettings.Name);

// Set the Name property to "LastAccessDate".
profilePropertySettings.Name = "LastAccessDate";

// Display all current ProfileGroupSettings.
Console.WriteLine("Current ProfileGroupSettings:");
int PGSCtr = 0;
foreach (ProfileGroupSettings propGroups in profileSection.PropertySettings.GroupSettings)
{
    Console.WriteLine("  {0}: ProfileGroupSetting '{1}'", ++PGSCtr,
        propGroups.Name);
    int PPSCtr = 0;
    foreach (ProfilePropertySettings props in propGroups.PropertySettings)
    {
        Console.WriteLine("    {0}: ProfilePropertySetting '{1}'", ++PPSCtr,
            props.Name);
    }
}

// Add a new group.
ProfileGroupSettings newPropGroup = new ProfileGroupSettings("Forum");
profileSection.PropertySettings.GroupSettings.Add(newPropGroup);

// Add a new PropertySettings to the group.
ProfilePropertySettings newProp = new ProfilePropertySettings("AvatarImage");
newProp.Type = "System.String, System.dll";
newPropGroup.PropertySettings.Add(newProp);

// Remove a PropertySettings from the group.
newPropGroup.PropertySettings.Remove("AvatarImage");
newPropGroup.PropertySettings.RemoveAt(0);

// Clear all PropertySettings from the group.
newPropGroup.PropertySettings.Clear();


' Display all current root ProfilePropertySettings.
Console.WriteLine("Current Root ProfilePropertySettings:")
Dim rootPPSCtr As Integer = 0
For Each rootPPS As ProfilePropertySettings In profileSection.PropertySettings
    Console.WriteLine("  {0}: ProfilePropertySetting '{1}'", ++rootPPSCtr, _
        rootPPS.Name)
Next

' Get and modify a root ProfilePropertySettings object.
Console.WriteLine( _
    "Display and modify 'LastReadDate' ProfilePropertySettings:")
Dim profilePropertySettings As ProfilePropertySettings = _
    profileSection.PropertySettings("LastReadDate")

' Get the current ReadOnly property value.
Console.WriteLine( _
    "Current ReadOnly value: '{0}'", profilePropertySettings.ReadOnly)

' Set the ReadOnly property to true.
profilePropertySettings.ReadOnly = true

' Get the current AllowAnonymous property value.
Console.WriteLine( _
    "Current AllowAnonymous value: '{0}'", profilePropertySettings.AllowAnonymous)

' Set the AllowAnonymous property to true.
profilePropertySettings.AllowAnonymous = true

' Get the current SerializeAs property value.
Console.WriteLine( _
    "Current SerializeAs value: '{0}'", profilePropertySettings.SerializeAs)

' Set the SerializeAs property to SerializationMode.Binary.
profilePropertySettings.SerializeAs = SerializationMode.Binary

' Get the current Type property value.
Console.WriteLine( _
    "Current Type value: '{0}'", profilePropertySettings.Type)

' Set the Type property to "System.DateTime".
profilePropertySettings.Type = "System.DateTime"

' Get the current DefaultValue property value.
Console.WriteLine( _
    "Current DefaultValue value: '{0}'", profilePropertySettings.DefaultValue)

' Set the DefaultValue property to "March 16, 2004".
profilePropertySettings.DefaultValue = "March 16, 2004"

' Get the current ProviderName property value.
            Console.WriteLine( _
                "Current ProviderName value: '{0}'", profilePropertySettings.Provider)

' Set the ProviderName property to "AspNetSqlRoleProvider".
            profilePropertySettings.Provider = "AspNetSqlRoleProvider"

' Get the current Name property value.
Console.WriteLine( _
    "Current Name value: '{0}'", profilePropertySettings.Name)

' Set the Name property to "LastAccessDate".
profilePropertySettings.Name = "LastAccessDate"

' Display all current ProfileGroupSettings.
Console.WriteLine("Current ProfileGroupSettings:")
Dim PGSCtr As Integer = 0
For Each propGroups As ProfileGroupSettings In profileSection.PropertySettings.GroupSettings
                    Console.WriteLine("  {0}: ProfileGroupSettings '{1}'", ++PGSCtr, _
        propGroups.Name)
    Dim PPSCtr As Integer = 0
    For Each props As ProfilePropertySettings In propGroups.PropertySettings
        Console.WriteLine("    {0}: ProfilePropertySetting '{1}'", ++PPSCtr, _
            props.Name)
    Next
Next

' Add a new group.
Dim newPropGroup As ProfileGroupSettings = new ProfileGroupSettings("Forum")
profileSection.PropertySettings.GroupSettings.Add(newPropGroup)

' Add a new PropertySettings to the group.
Dim newProp As ProfilePropertySettings = new ProfilePropertySettings("AvatarImage")
newProp.Type = "System.String, System.dll"
newPropGroup.PropertySettings.Add(newProp)

' Remove a PropertySettings from the group.
newPropGroup.PropertySettings.Remove("AvatarImage")
newPropGroup.PropertySettings.RemoveAt(0)

' Clear all PropertySettings from the group.
newPropGroup.PropertySettings.Clear()

注解

RootProfilePropertySettingsCollection 类既是根级 ProfilePropertySettingsCollection 集合,也是集合的 ProfileGroupSettingsCollection 容器。 通过这些集合,可以创建更多 ProfilePropertySettingsCollection 集合的命名组,每个集合都包含单独的命名 ProfilePropertySettings 对象。 有关添加到 ASP.NET 2.0 的配置文件功能的详细信息,请参阅 ASP.NET 配置文件属性

PropertySettings属性是一个RootProfilePropertySettingsCollection对象,该对象包含配置文件节的子节propertiesprofile定义的所有属性。

构造函数

名称 说明
RootProfilePropertySettingsCollection()

使用默认设置初始化类的新实例 RootProfilePropertySettingsCollection

属性

名称 说明
AddElementName

获取或设置在派生类中重写时要与 ConfigurationElement 中的添加操作关联的 ConfigurationElementCollection 的名称。

(继承自 ConfigurationElementCollection)
AllKeys

返回一个数组,该数组包含集合中包含的所有 ProfileSection 对象的名称。

(继承自 ProfilePropertySettingsCollection)
AllowClear

获取一个值,该值指示 clear< 元素是否>作为ProfilePropertySettings对象有效。

(继承自 ProfilePropertySettingsCollection)
ClearElementName

获取或设置在派生类中重写时要与 ConfigurationElement 中的清除操作关联的 ConfigurationElementCollection 的名称。

(继承自 ConfigurationElementCollection)
CollectionType

获取 ConfigurationElementCollection的类型。

(继承自 ConfigurationElementCollection)
Count

获取集合中的元素数。

(继承自 ConfigurationElementCollection)
CurrentConfiguration

获取对顶级 Configuration 实例的引用,该实例表示当前 ConfigurationElement 实例所属的配置层次结构。

(继承自 ConfigurationElement)
ElementInformation

获取一个 ElementInformation 对象,该对象包含 ConfigurationElement 对象的不可自定义信息和功能。

(继承自 ConfigurationElement)
ElementName

获取在派生类中重写时用于标识配置文件中此元素集合的名称。

(继承自 ConfigurationElementCollection)
ElementProperty

获取表示 ConfigurationElementProperty 对象本身的 ConfigurationElement 对象。

(继承自 ConfigurationElement)
EmitClear

获取或设置一个值,该值指定集合是否已清除。

(继承自 ConfigurationElementCollection)
EvaluationContext

获取 ContextInformation 对象的 ConfigurationElement 对象。

(继承自 ConfigurationElement)
GroupSettings

ProfileGroupSettingsCollection获取包含对象的集合ProfileGroupSettings

HasContext

获取一个值,该值指示 CurrentConfiguration 属性是否 null

(继承自 ConfigurationElement)
IsSynchronized

获取一个值,该值指示是否同步对集合的访问。

(继承自 ConfigurationElementCollection)
Item[ConfigurationProperty]

获取或设置此配置元素的属性或属性。

(继承自 ConfigurationElement)
Item[Int32]

获取或设置 ProfilePropertySettings 位于指定索引位置的对象。

(继承自 ProfilePropertySettingsCollection)
Item[String]

获取或设置 ProfilePropertySettings 具有指定名称的对象。

(继承自 ProfilePropertySettingsCollection)
LockAllAttributesExcept

获取锁定属性的集合。

(继承自 ConfigurationElement)
LockAllElementsExcept

获取锁定元素的集合。

(继承自 ConfigurationElement)
LockAttributes

获取锁定属性的集合。

(继承自 ConfigurationElement)
LockElements

获取锁定元素的集合。

(继承自 ConfigurationElement)
LockItem

获取或设置一个值,该值指示元素是否已锁定。

(继承自 ConfigurationElement)
Properties

获取配置属性的集合。

(继承自 ProfilePropertySettingsCollection)
RemoveElementName

获取或设置在派生类中重写时要与 ConfigurationElement 中删除操作关联的 ConfigurationElementCollection 的名称。

(继承自 ConfigurationElementCollection)
SyncRoot

获取一个对象,该对象用于同步对 ConfigurationElementCollection的访问。

(继承自 ConfigurationElementCollection)
ThrowOnDuplicate

获取一个值,该值指示在尝试创建重复对象时是否应引发错误。

(继承自 ProfilePropertySettingsCollection)

方法

名称 说明
Add(ProfilePropertySettings)

将对象 ProfilePropertySettings 添加到集合。

(继承自 ProfilePropertySettingsCollection)
BaseAdd(ConfigurationElement, Boolean)

将配置元素添加到配置元素集合。

(继承自 ConfigurationElementCollection)
BaseAdd(ConfigurationElement)

将配置元素添加到 ConfigurationElementCollection

(继承自 ConfigurationElementCollection)
BaseAdd(Int32, ConfigurationElement)

将配置元素添加到配置元素集合。

(继承自 ConfigurationElementCollection)
BaseClear()

从集合中删除所有配置元素对象。

(继承自 ConfigurationElementCollection)
BaseGet(Int32)

获取位于指定索引位置的配置元素。

(继承自 ConfigurationElementCollection)
BaseGet(Object)

返回具有指定键的配置元素。

(继承自 ConfigurationElementCollection)
BaseGetAllKeys()

返回 ConfigurationElementCollection中包含的所有配置元素的键数组。

(继承自 ConfigurationElementCollection)
BaseGetKey(Int32)

获取指定索引位置处 ConfigurationElement 的键。

(继承自 ConfigurationElementCollection)
BaseIndexOf(ConfigurationElement)

指示指定 ConfigurationElement的索引。

(继承自 ConfigurationElementCollection)
BaseIsRemoved(Object)

指示是否已从 ConfigurationElement中删除具有指定键的 ConfigurationElementCollection

(继承自 ConfigurationElementCollection)
BaseRemove(Object)

从集合中删除 ConfigurationElement

(继承自 ConfigurationElementCollection)
BaseRemoveAt(Int32)

删除位于指定索引位置的 ConfigurationElement

(继承自 ConfigurationElementCollection)
Clear()

从集合中删除所有 ProfilePropertySettings 对象。

(继承自 ProfilePropertySettingsCollection)
CopyTo(ConfigurationElement[], Int32)

ConfigurationElementCollection 的内容复制到数组。

(继承自 ConfigurationElementCollection)
CreateNewElement()

在派生类中重写时,创建新的 ConfigurationElement

(继承自 ProfilePropertySettingsCollection)
CreateNewElement(String)

在派生类中重写时创建新的 ConfigurationElement

(继承自 ConfigurationElementCollection)
DeserializeElement(XmlReader, Boolean)

从配置文件中读取 XML。

(继承自 ConfigurationElement)
Equals(Object)

将当前 RootProfilePropertySettingsCollection 对象与另一个 A RootProfilePropertySettingsCollection 对象进行比较。

Get(Int32)

返回 ProfileSection 指定索引处的对象。

(继承自 ProfilePropertySettingsCollection)
Get(String)

返回 ProfileSection 具有指定名称的对象。

(继承自 ProfilePropertySettingsCollection)
GetElementKey(ConfigurationElement)

获取指定配置元素的键。

(继承自 ProfilePropertySettingsCollection)
GetEnumerator()

获取用于循环访问的IEnumerator一个 ConfigurationElementCollection

(继承自 ConfigurationElementCollection)
GetHashCode()

生成集合的哈希代码。

GetKey(Int32)

获取位于指定索引位置的名称 ProfilePropertySettings

(继承自 ProfilePropertySettingsCollection)
GetTransformedAssemblyString(String)

返回指定程序集名称的转换版本。

(继承自 ConfigurationElement)
GetTransformedTypeString(String)

返回指定类型名称的转换版本。

(继承自 ConfigurationElement)
GetType()

获取当前实例的 Type

(继承自 Object)
IndexOf(ProfilePropertySettings)

返回指定 ProfilePropertySettings 对象的索引。

(继承自 ProfilePropertySettingsCollection)
Init()

ConfigurationElement 对象设置为其初始状态。

(继承自 ConfigurationElement)
InitializeDefault()

用于初始化 ConfigurationElement 对象的默认值集。

(继承自 ConfigurationElement)
IsElementName(String)

指示指定的 ConfigurationElement 是否存在于 ConfigurationElementCollection中。

(继承自 ConfigurationElementCollection)
IsElementRemovable(ConfigurationElement)

指示是否可以从 ConfigurationElement中删除指定的 ConfigurationElementCollection

(继承自 ConfigurationElementCollection)
IsModified()

指示在派生类中重写此 ConfigurationElementCollection 自上次保存或加载以来是否已修改。

(继承自 ConfigurationElementCollection)
IsReadOnly()

指示 ConfigurationElementCollection 对象是否为只读。

(继承自 ConfigurationElementCollection)
ListErrors(IList)

将此 ConfigurationElement 对象和所有子元素中的无效属性错误添加到传递的列表。

(继承自 ConfigurationElement)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
OnDeserializeUnrecognizedAttribute(String, String)

获取一个值,该值指示在反序列化期间是否遇到未知属性。

(继承自 ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

处理从配置文件中读取无法识别的配置元素,并在无法处理该元素时导致配置系统引发异常。

(继承自 ProfilePropertySettingsCollection)
OnRequiredPropertyNotFound(String)

在找不到所需属性时引发异常。

(继承自 ConfigurationElement)
PostDeserialize()

反序列化后调用。

(继承自 ConfigurationElement)
PreSerialize(XmlWriter)

在序列化之前调用。

(继承自 ConfigurationElement)
Remove(String)

ProfilePropertySettings 集合中删除对象。

(继承自 ProfilePropertySettingsCollection)
RemoveAt(Int32)

ProfilePropertySettings从集合中移除位于指定索引位置的对象。

(继承自 ProfilePropertySettingsCollection)
Reset(ConfigurationElement)

在派生类中重写时,将 ConfigurationElementCollection 重置为其未修改的状态。

(继承自 ConfigurationElementCollection)
ResetModified()

在派生类中重写时,将 IsModified() 属性的值重置为 false

(继承自 ConfigurationElementCollection)
SerializeElement(XmlWriter, Boolean)

在派生类中重写时,将配置数据写入配置文件中的 XML 元素。

(继承自 ConfigurationElementCollection)
SerializeToXmlElement(XmlWriter, String)

在派生类中实现时,将此配置元素的外部标记写入配置文件。

(继承自 ConfigurationElement)
Set(ProfilePropertySettings)

将指定的 ProfilePropertySettings 对象添加到集合中。

(继承自 ProfilePropertySettingsCollection)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

将属性设置为指定的值。

(继承自 ConfigurationElement)
SetReadOnly()

设置 IsReadOnly() 对象和所有子元素的 ConfigurationElementCollection 属性。

(继承自 ConfigurationElementCollection)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

反转从配置层次结构的不同级别合并配置信息的效果。

(继承自 ConfigurationElementCollection)

显式接口实现

名称 说明
ICollection.CopyTo(Array, Int32)

ConfigurationElementCollection 复制到数组。

(继承自 ConfigurationElementCollection)

扩展方法

名称 说明
AsParallel(IEnumerable)

启用查询的并行化。

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryable

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定类型。

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。

适用于

另请参阅