ConfigurationSection.ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName) 方法

定义

指示在为指定的 .NET Framework 目标版本序列化配置对象层次结构时,是否应序列化指定的元素。Indicates whether the specified element should be serialized when the configuration object hierarchy is serialized for the specified target version of the .NET Framework.

protected:
 virtual bool ShouldSerializeElementInTargetVersion(System::Configuration::ConfigurationElement ^ element, System::String ^ elementName, System::Runtime::Versioning::FrameworkName ^ targetFramework);
protected public:
 virtual bool ShouldSerializeElementInTargetVersion(System::Configuration::ConfigurationElement ^ element, System::String ^ elementName, System::Runtime::Versioning::FrameworkName ^ targetFramework);
protected virtual bool ShouldSerializeElementInTargetVersion (System.Configuration.ConfigurationElement element, string elementName, System.Runtime.Versioning.FrameworkName targetFramework);
protected internal virtual bool ShouldSerializeElementInTargetVersion (System.Configuration.ConfigurationElement element, string elementName, System.Runtime.Versioning.FrameworkName targetFramework);
abstract member ShouldSerializeElementInTargetVersion : System.Configuration.ConfigurationElement * string * System.Runtime.Versioning.FrameworkName -> bool
override this.ShouldSerializeElementInTargetVersion : System.Configuration.ConfigurationElement * string * System.Runtime.Versioning.FrameworkName -> bool
Protected Overridable Function ShouldSerializeElementInTargetVersion (element As ConfigurationElement, elementName As String, targetFramework As FrameworkName) As Boolean
Protected Friend Overridable Function ShouldSerializeElementInTargetVersion (element As ConfigurationElement, elementName As String, targetFramework As FrameworkName) As Boolean

参数

element
ConfigurationElement

作为候选序列化对象的 ConfigurationElement 对象。The ConfigurationElement object that is a candidate for serialization.

elementName
String

ConfigurationElement 对象出现在 XML 中的名称。The name of the ConfigurationElement object as it occurs in XML.

targetFramework
FrameworkName

.NET Framework 的目标版本。The target version of the .NET Framework.

返回

Boolean

如果应序列化 element,则为 true;否则为 falsetrue if the element should be serialized; otherwise, false.

注解

为 .NET Framework 4 及更高版本创建的每个配置节必须显式重写此方法并返回 true ,但前提是指定的元素对于 .NET Framework 的指定版本有效。Each configuration section that is created for the .NET Framework 4 and later versions must explicitly override this method and return true, but only if the specified element is valid for the specified version of the .NET Framework. 为 .NET Framework 早期版本创建的现有配置节不必更改。Existing configuration sections that were created for earlier versions of the .NET Framework do not have to be changed.

基类型包含此方法的默认实现,该实现始终返回 trueThe base type contains a default implementation of this method that always returns true. 如果实现配置节并且不重写此方法,则默认情况下,将为所有框架版本序列化配置节中包含的所有配置元素。If you implement a configuration section and you do not override this method, by default all configuration elements that are contained in the configuration section will be serialized for all framework versions.

适用于