ConfigurationSection.ShouldSerializePropertyInTargetVersion(ConfigurationProperty, String, FrameworkName, ConfigurationElement) 方法

定义

指示在为指定目标版本的 .NET Framework.NET Framework 序列化配置对象层次结构时,是否应序列化指定属性。Indicates whether the specified property 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 ShouldSerializePropertyInTargetVersion(System::Configuration::ConfigurationProperty ^ property, System::String ^ propertyName, System::Runtime::Versioning::FrameworkName ^ targetFramework, System::Configuration::ConfigurationElement ^ parentConfigurationElement);
protected internal virtual bool ShouldSerializePropertyInTargetVersion (System.Configuration.ConfigurationProperty property, string propertyName, System.Runtime.Versioning.FrameworkName targetFramework, System.Configuration.ConfigurationElement parentConfigurationElement);
abstract member ShouldSerializePropertyInTargetVersion : System.Configuration.ConfigurationProperty * string * System.Runtime.Versioning.FrameworkName * System.Configuration.ConfigurationElement -> bool
override this.ShouldSerializePropertyInTargetVersion : System.Configuration.ConfigurationProperty * string * System.Runtime.Versioning.FrameworkName * System.Configuration.ConfigurationElement -> bool
Protected Friend Overridable Function ShouldSerializePropertyInTargetVersion (property As ConfigurationProperty, propertyName As String, targetFramework As FrameworkName, parentConfigurationElement As ConfigurationElement) As Boolean

参数

property
ConfigurationProperty

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

propertyName
String

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

targetFramework
FrameworkName

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

parentConfigurationElement
ConfigurationElement

属性的父元素。The parent element of the property.

返回

如果应序列化 property,则为 true;否则为 falsetrue if the property 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 property 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 properties that are contained in the configuration section will be serialized for all framework versions.

适用于

另请参阅