TagPrefixCollection 类
定义
包含 TagPrefixInfo 对象的集合。Contains a collection of TagPrefixInfo objects.
public ref class TagPrefixCollection sealed : System::Configuration::ConfigurationElementCollection
[System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.TagPrefixInfo), AddItemName="add", CollectionType=System.Configuration.ConfigurationElementCollectionType.BasicMap)]
public sealed class TagPrefixCollection : System.Configuration.ConfigurationElementCollection
[<System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.TagPrefixInfo), AddItemName="add", CollectionType=System.Configuration.ConfigurationElementCollectionType.BasicMap)>]
type TagPrefixCollection = class
inherit ConfigurationElementCollection
Public NotInheritable Class TagPrefixCollection
Inherits ConfigurationElementCollection
- 继承
- 属性
示例
下面的配置文件节选显示了如何以声明方式为类型的多个属性指定值 TagPrefixCollection 。The following configuration file excerpt shows how to declaratively specify values for several properties of the TagPrefixCollection type.
<system.web>
<pages>
<controls>
<clear />
<remove tagPrefix="MyTags" />
<!-- Searches all linked assemblies for the namespace -->
<add tagPrefix="MyTags1" namespace=" MyNameSpace "/>
<!-- Uses a specified assembly -->
<add tagPrefix="MyTags2" namespace="MyNameSpace"
assembly="MyAssembly"/>
<!-- Uses the specified source for the user control -->
<add tagprefix="MyTags3" tagname="MyCtrl" src="MyControl.ascx"/>
</controls>
</pages>
</system.web>
下面的代码示例演示如何使用类以 TagPrefixCollection 编程方式修改标记前缀设置。The following code example shows how to use the TagPrefixCollection class to programmatically modify tag-prefix settings. 此代码示例是为类提供的更大示例的一部分 PagesSection 。This code example is part of a larger example provided for the PagesSection class.
// Get all current Controls in the collection.
for (int i = 0; i < pagesSection.Controls.Count; i++)
{
Console.WriteLine("Control {0}:", i);
Console.WriteLine(" TagPrefix = '{0}' ",
pagesSection.Controls[i].TagPrefix);
Console.WriteLine(" TagName = '{0}' ",
pagesSection.Controls[i].TagName);
Console.WriteLine(" Source = '{0}' ",
pagesSection.Controls[i].Source);
Console.WriteLine(" Namespace = '{0}' ",
pagesSection.Controls[i].Namespace);
Console.WriteLine(" Assembly = '{0}' ",
pagesSection.Controls[i].Assembly);
}
// Create a new TagPrefixInfo object.
System.Web.Configuration.TagPrefixInfo tagPrefixInfo =
new System.Web.Configuration.TagPrefixInfo("MyCtrl", "MyNameSpace", "MyAssembly", "MyControl", "MyControl.ascx");
// Execute the Add Method.
pagesSection.Controls.Add(tagPrefixInfo);
// Add a TagPrefixInfo object using a constructor.
pagesSection.Controls.Add(
new System.Web.Configuration.TagPrefixInfo(
"MyCtrl", "MyNameSpace", "MyAssembly", "MyControl",
"MyControl.ascx"));
' Get all current Controls in the collection.
Dim j As Int32
For j = 0 To pagesSection.Controls.Count - 1
Console.WriteLine("Control {0}:", j)
Console.WriteLine(" TagPrefix = '{0}' ", _
pagesSection.Controls(j).TagPrefix)
Console.WriteLine(" TagName = '{0}' ", _
pagesSection.Controls(j).TagName)
Console.WriteLine(" Source = '{0}' ", _
pagesSection.Controls(j).Source)
Console.WriteLine(" Namespace = '{0}' ", _
pagesSection.Controls(j).Namespace)
Console.WriteLine(" Assembly = '{0}' ", _
pagesSection.Controls(j).Assembly)
Next
' Create a new TagPrefixInfo object.
Dim tagPrefixInfo As System.Web.Configuration.TagPrefixInfo = _
New System.Web.Configuration.TagPrefixInfo("MyCtrl", "MyNameSpace", "MyAssembly", "MyControl", "MyControl.ascx")
' Execute the Add Method.
pagesSection.Controls.Add(tagPrefixInfo)
' Add a TagPrefixInfo object using a constructor.
pagesSection.Controls.Add( _
New System.Web.Configuration.TagPrefixInfo( _
"MyCtrl", "MyNameSpace", "MyAssembly", "MyControl", _
"MyControl.ascx"))
注解
TagPrefixInfo类可让你以编程方式访问和修改存储在配置文件中的标记前缀信息。The TagPrefixInfo class allows you to programmatically access and modify tag-prefix information stored in a configuration file. 标记前缀将 ASP.NET 中的 "命名空间" 关联到自定义控件和用户控件正常工作时必须包含的程序集和命名空间。Tag prefixes associate a "namespace" in ASP.NET with the assemblies and namespaces that must be included for custom controls and user controls to work properly.
TagPrefixInfo 对象存储为对象的成员 TagPrefixCollection 。TagPrefixInfo objects are stored as members of a TagPrefixCollection object. TagPrefixCollection类允许以编程方式访问和修改 controls pages 配置文件的节的子节。The TagPrefixCollection class allows you to programmatically access and modify the controls subsection of the pages section of a configuration file.
构造函数
| TagPrefixCollection() |
创建 TagPrefixCollection 类的新实例。Creates a new instance of the TagPrefixCollection class. |
属性
| AddElementName |
在派生的类中重写时,获取或设置 ConfigurationElement 的名称,以便在 ConfigurationElementCollection 中与添加操作关联。Gets or sets the name of the ConfigurationElement to associate with the add operation in the ConfigurationElementCollection when overridden in a derived class. (继承自 ConfigurationElementCollection) |
| ClearElementName |
在派生的类中重写时,获取或设置 ConfigurationElement 的名称,以便在 ConfigurationElementCollection 中与清除操作关联。Gets or sets the name for the ConfigurationElement to associate with the clear operation in the ConfigurationElementCollection when overridden in a derived class. (继承自 ConfigurationElementCollection) |
| CollectionType |
获取配置集合的类型。Gets the type of the configuration collection. |
| Count |
获取集合中的元素数。Gets the number of elements in the collection. (继承自 ConfigurationElementCollection) |
| CurrentConfiguration |
获取对顶级 Configuration 实例的引用,该实例表示当前 ConfigurationElement 实例所属的配置层次结构。Gets a reference to the top-level Configuration instance that represents the configuration hierarchy that the current ConfigurationElement instance belongs to. (继承自 ConfigurationElement) |
| ElementInformation |
获取包含 ConfigurationElement 对象的不可自定义的信息和功能的 ElementInformation 对象。Gets an ElementInformation object that contains the non-customizable information and functionality of the ConfigurationElement object. (继承自 ConfigurationElement) |
| ElementName |
获取在派生的类中重写时用于标识配置文件中此元素集合的名称。Gets the name used to identify this collection of elements in the configuration file when overridden in a derived class. (继承自 ConfigurationElementCollection) |
| ElementProperty |
获取表示 ConfigurationElement 对象本身的 ConfigurationElementProperty 对象。Gets the ConfigurationElementProperty object that represents the ConfigurationElement object itself. (继承自 ConfigurationElement) |
| EmitClear |
获取或设置一个值,该值指定是否已清除集合。Gets or sets a value that specifies whether the collection has been cleared. (继承自 ConfigurationElementCollection) |
| EvaluationContext |
获取 ConfigurationElement 对象的 ContextInformation 对象。Gets the ContextInformation object for the ConfigurationElement object. (继承自 ConfigurationElement) |
| HasContext |
获取一个值,该值指示 CurrentConfiguration 属性是否为 |
| IsSynchronized |
获取一个值,该值指示是否同步对集合的访问。Gets a value indicating whether access to the collection is synchronized. (继承自 ConfigurationElementCollection) |
| Item[ConfigurationProperty] |
获取或设置此配置元素的属性或特性。Gets or sets a property or attribute of this configuration element. (继承自 ConfigurationElement) |
| Item[Int32] |
获取或设置位于指定索引位置的 TagPrefixInfo 对象。Gets or sets the TagPrefixInfo object at the specified index location. |
| Item[String] |
获取或设置此配置元素的属性、特性或子元素。Gets or sets a property, attribute, or child element of this configuration element. (继承自 ConfigurationElement) |
| LockAllAttributesExcept |
获取被锁定的特性的集合。Gets the collection of locked attributes. (继承自 ConfigurationElement) |
| LockAllElementsExcept |
获取被锁定的元素的集合。Gets the collection of locked elements. (继承自 ConfigurationElement) |
| LockAttributes |
获取被锁定的特性的集合。Gets the collection of locked attributes. (继承自 ConfigurationElement) |
| LockElements |
获取被锁定的元素的集合。Gets the collection of locked elements. (继承自 ConfigurationElement) |
| LockItem |
获取或设置一个值,该值指示是否已锁定该元素。Gets or sets a value indicating whether the element is locked. (继承自 ConfigurationElement) |
| Properties |
获取属性的集合。Gets the collection of properties. (继承自 ConfigurationElement) |
| RemoveElementName |
在派生的类中重写时,获取或设置 ConfigurationElement 的名称,以便在 ConfigurationElementCollection 中与移除操作关联。Gets or sets the name of the ConfigurationElement to associate with the remove operation in the ConfigurationElementCollection when overridden in a derived class. (继承自 ConfigurationElementCollection) |
| SyncRoot |
获取用于同步对 ConfigurationElementCollection 的访问的对象。Gets an object used to synchronize access to the ConfigurationElementCollection. (继承自 ConfigurationElementCollection) |
| ThrowOnDuplicate |
获取一个值,该值指示尝试向 ConfigurationElement 添加重复的 ConfigurationElementCollection 是否会导致引发异常。Gets a value indicating whether an attempt to add a duplicate ConfigurationElement to the ConfigurationElementCollection will cause an exception to be thrown. (继承自 ConfigurationElementCollection) |
方法
| Add(TagPrefixInfo) |
将 TagPrefixInfo 对象添加到集合中。Adds a TagPrefixInfo object to the collection. |
| BaseAdd(ConfigurationElement) |
向 ConfigurationElementCollection 添加配置元素。Adds a configuration element to the ConfigurationElementCollection. (继承自 ConfigurationElementCollection) |
| BaseAdd(ConfigurationElement, Boolean) |
向配置元素集合添加配置元素。Adds a configuration element to the configuration element collection. (继承自 ConfigurationElementCollection) |
| BaseAdd(Int32, ConfigurationElement) |
向配置元素集合添加配置元素。Adds a configuration element to the configuration element collection. (继承自 ConfigurationElementCollection) |
| BaseClear() |
从集合中移除所有配置元素对象。Removes all configuration element objects from the collection. (继承自 ConfigurationElementCollection) |
| BaseGet(Int32) |
获取位于指定索引位置的配置元素。Gets the configuration element at the specified index location. (继承自 ConfigurationElementCollection) |
| BaseGet(Object) |
返回具有指定键的配置元素。Returns the configuration element with the specified key. (继承自 ConfigurationElementCollection) |
| BaseGetAllKeys() |
返回 ConfigurationElementCollection 中包含的所有配置元素的键数组。Returns an array of the keys for all of the configuration elements contained in the ConfigurationElementCollection. (继承自 ConfigurationElementCollection) |
| BaseGetKey(Int32) |
获取位于指定索引位置的 ConfigurationElement 的键。Gets the key for the ConfigurationElement at the specified index location. (继承自 ConfigurationElementCollection) |
| BaseIndexOf(ConfigurationElement) |
获取指定的 ConfigurationElement 的索引。Indicates the index of the specified ConfigurationElement. (继承自 ConfigurationElementCollection) |
| BaseIsRemoved(Object) |
指示是否已从 ConfigurationElement 中移除具有指定键的 ConfigurationElementCollection。Indicates whether the ConfigurationElement with the specified key has been removed from the ConfigurationElementCollection. (继承自 ConfigurationElementCollection) |
| BaseRemove(Object) |
从集合中删除 ConfigurationElement 对象。Removes a ConfigurationElement from the collection. (继承自 ConfigurationElementCollection) |
| BaseRemoveAt(Int32) |
移除位于指定索引位置的 ConfigurationElement。Removes the ConfigurationElement at the specified index location. (继承自 ConfigurationElementCollection) |
| Clear() |
清除集合中的所有对象。Clears all object from the collection. |
| CopyTo(ConfigurationElement[], Int32) |
将 ConfigurationElementCollection 的内容复制到数组。Copies the contents of the ConfigurationElementCollection to an array. (继承自 ConfigurationElementCollection) |
| CreateNewElement() |
在派生的类中重写时,创建一个新的 ConfigurationElement。When overridden in a derived class, creates a new ConfigurationElement. (继承自 ConfigurationElementCollection) |
| CreateNewElement(String) |
在派生的类中重写时,创建新的 ConfigurationElement。Creates a new ConfigurationElement when overridden in a derived class. (继承自 ConfigurationElementCollection) |
| DeserializeElement(XmlReader, Boolean) |
从配置文件读取 XML。Reads XML from the configuration file. (继承自 ConfigurationElement) |
| Equals(Object) |
将 ConfigurationElementCollection 与指定的对象进行比较。Compares the ConfigurationElementCollection to the specified object. (继承自 ConfigurationElementCollection) |
| GetElementKey(ConfigurationElement) |
在派生类中重写时获取指定配置元素的元素键。Gets the element key for a specified configuration element when overridden in a derived class. (继承自 ConfigurationElementCollection) |
| GetEnumerator() |
获取用于循环访问 IEnumerator 的 ConfigurationElementCollection。Gets an IEnumerator which is used to iterate through the ConfigurationElementCollection. (继承自 ConfigurationElementCollection) |
| GetHashCode() |
获取表示 ConfigurationElementCollection 实例的唯一值。Gets a unique value representing the ConfigurationElementCollection instance. (继承自 ConfigurationElementCollection) |
| GetTransformedAssemblyString(String) |
返回指定程序集名称的转换版本。Returns the transformed version of the specified assembly name. (继承自 ConfigurationElement) |
| GetTransformedTypeString(String) |
返回指定类型名称的转换版本。Returns the transformed version of the specified type name. (继承自 ConfigurationElement) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| Init() |
将 ConfigurationElement 对象设置为其初始状态。Sets the ConfigurationElement object to its initial state. (继承自 ConfigurationElement) |
| InitializeDefault() |
用于初始化 ConfigurationElement 对象的默认值集。Used to initialize a default set of values for the ConfigurationElement object. (继承自 ConfigurationElement) |
| IsElementName(String) |
指示指定的 ConfigurationElement 是否存在于 ConfigurationElementCollection 中。Indicates whether the specified ConfigurationElement exists in the ConfigurationElementCollection. (继承自 ConfigurationElementCollection) |
| IsElementRemovable(ConfigurationElement) |
指示是否可从 ConfigurationElement 中移除指定 ConfigurationElementCollection。Indicates whether the specified ConfigurationElement can be removed from the ConfigurationElementCollection. (继承自 ConfigurationElementCollection) |
| IsModified() |
在派生的类中重写时,指示从最后一次保存或加载此 ConfigurationElementCollection 后是否对其进行了修改。Indicates whether this ConfigurationElementCollection has been modified since it was last saved or loaded when overridden in a derived class. (继承自 ConfigurationElementCollection) |
| IsReadOnly() |
指示 ConfigurationElementCollection 对象是否为只读的。Indicates whether the ConfigurationElementCollection object is read only. (继承自 ConfigurationElementCollection) |
| ListErrors(IList) |
将此 ConfigurationElement 对象以及所有子元素中无效属性的错误添加到传递的列表中。Adds the invalid-property errors in this ConfigurationElement object, and in all subelements, to the passed list. (继承自 ConfigurationElement) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| OnDeserializeUnrecognizedAttribute(String, String) |
获取一个值,该值指示反序列化过程中是否遇到未知特性。Gets a value indicating whether an unknown attribute is encountered during deserialization. (继承自 ConfigurationElement) |
| OnDeserializeUnrecognizedElement(String, XmlReader) |
导致配置系统引发异常。Causes the configuration system to throw an exception. (继承自 ConfigurationElementCollection) |
| OnRequiredPropertyNotFound(String) |
找不到所需属性时引发异常。Throws an exception when a required property is not found. (继承自 ConfigurationElement) |
| PostDeserialize() |
反序列化后调用。Called after deserialization. (继承自 ConfigurationElement) |
| PreSerialize(XmlWriter) |
在序列化之前调用。Called before serialization. (继承自 ConfigurationElement) |
| Remove(TagPrefixInfo) |
从集合中删除指定的对象。Removes the specified object from the collection. |
| Reset(ConfigurationElement) |
在派生的类中重写时,将 ConfigurationElementCollection 重置为其未被修改时的状态。Resets the ConfigurationElementCollection to its unmodified state when overridden in a derived class. (继承自 ConfigurationElementCollection) |
| ResetModified() |
在派生的类中重写时,将 IsModified() 属性的值重置为 |
| SerializeElement(XmlWriter, Boolean) |
在派生的类中重写时,将配置数据写入配置文件中的 XML 元素。Writes the configuration data to an XML element in the configuration file when overridden in a derived class. (继承自 ConfigurationElementCollection) |
| SerializeToXmlElement(XmlWriter, String) |
当在派生类中实现后,将此配置元素的外部标记写入配置文件。Writes the outer tags of this configuration element to the configuration file when implemented in a derived class. (继承自 ConfigurationElement) |
| SetPropertyValue(ConfigurationProperty, Object, Boolean) |
将属性设置为指定值。Sets a property to the specified value. (继承自 ConfigurationElement) |
| SetReadOnly() |
为 IsReadOnly() 对象和所有子元素设置 ConfigurationElementCollection 属性。Sets the IsReadOnly() property for the ConfigurationElementCollection object and for all sub-elements. (继承自 ConfigurationElementCollection) |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |
| Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode) |
反转从配置层次结构的不同级别合并配置信息的效果。Reverses the effect of merging configuration information from different levels of the configuration hierarchy. (继承自 ConfigurationElementCollection) |
显式接口实现
| ICollection.CopyTo(Array, Int32) |
将 ConfigurationElementCollection 复制到数组。Copies the ConfigurationElementCollection to an array. (继承自 ConfigurationElementCollection) |
扩展方法
| Cast<TResult>(IEnumerable) |
将 IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type. |
| OfType<TResult>(IEnumerable) |
根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type. |
| AsParallel(IEnumerable) |
启用查询的并行化。Enables parallelization of a query. |
| AsQueryable(IEnumerable) |
将 IEnumerable 转换为 IQueryable。Converts an IEnumerable to an IQueryable. |