ConfigurationSection.ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName) ConfigurationSection.ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName) ConfigurationSection.ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName) ConfigurationSection.ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName) Method

定义

指示在为 .NET Framework.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.NET Framework.

protected public:
 virtual bool ShouldSerializeElementInTargetVersion(System::Configuration::ConfigurationElement ^ element, System::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 Friend Overridable Function ShouldSerializeElementInTargetVersion (element As ConfigurationElement, elementName As String, targetFramework As FrameworkName) As Boolean

参数

element
ConfigurationElement ConfigurationElement ConfigurationElement ConfigurationElement

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

elementName
String String String String

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

targetFramework
FrameworkName FrameworkName FrameworkName FrameworkName

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

返回

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

注解

.NET Framework 4.NET Framework 4及更高版本创建的每个配置节必须显式重写此方法并true返回,但前提是指定的元素对于指定的版本.NET Framework.NET Framework有效。Each configuration section that is created for the .NET Framework 4.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. 为的早期版本.NET Framework.NET Framework创建的现有配置节不必更改。Existing configuration sections that were created for earlier versions of the .NET Framework.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.

适用于

另请参阅