Επεξεργασία

Κοινή χρήση μέσω


ChartSerializer Class

Definition

Enables serialization of the Chart control.

public ref class ChartSerializer
public class ChartSerializer
type ChartSerializer = class
Public Class ChartSerializer
Inheritance
ChartSerializer

Remarks

This class is exposed as the Serializer property of the root Chart class.

Serialization saves the state of the chart and also provides the option to load the serialized data into the chart. All chart properties can be persisted, including the chart's data. In addition, all chart properties marked for serialization can be reset.

This class can optionally be used when managing user-defined view state. One of its Load methods can be used to load the view state, and one of the Save methods can be used when setting the view state.

The XML or binary formats can be used to store serialized data. XML is used by default, but you can change the format with the Format property.

Chart properties are saved and loaded using the Save and Load methods, respectively. Note that only properties with non-default values will be saved. Data can be saved and/or loaded using a file, stream, TextWriter, TextReader, XmlWriter and XmlReader objects. When saving and/or loading data using an object derived from the TextReader, TextWriter, XmlReader or XmlWriter classes, the format of the data must be XML.

The following list describes three techniques, from basic to advanced, used to define serializable data. Note that it is also possible to define non-serializable data. This technique is described in the next paragraph.

  • Serialize the Chart using the Save and Load methods, without specifying any serializable properties. All chart properties with non-default values, which includes chart data, will be serialized.

  • Serialize the chart properties specified by the Content property. The Content property groups the chart properties to be serialized into categories such as Data, Appearance, and so forth. Note that the names of ChartArea and Series objects are automatically serialized; the serialized data is then applied to existing chart areas and series when loaded.

Important

The Content property is implemented internally by the Chart control as the SerializableContent property

  • Serialization of chart properties specified by the SerializableContent property. This is a comma-separated listing of all chart properties that are serializable. After this property is set to an explicit value, it is the responsibility of the developer to specify all properties to be saved. In other words, unlike the Content property, the names of chart areas and series will not be automatically persisted. The Content and SerializableContent properties can also be used in conjunction. However, make sure that SerializableContent is concatenated with itself when being set, otherwise the chart properties specified by the Content property will be overridden.

To prohibit certain properties from being serialized, use the NonSerializableContent property. When one property is set as serializable and non-serializable, which is common when wildcards are used, the SerializableContent property has precedence. However, precedence also depends on how many wildcards were used when a property was specified.

By default, serializable properties are reset to their defaults before they are loaded. This behavior can be changed using the IsResetWhenLoading property. The Reset method can also be used to explicitly reset chart properties to their default values.

Properties

Content

Gets or sets the type of chart content to be serialized.

Format

Gets or sets the format used when the chart is serialized.

IsResetWhenLoading

Gets or sets a flag that indicates whether object properties are reset to default values before loading.

IsTemplateMode

Gets or sets a flag that indicates whether the chart serializer is working in template-creation mode.

IsUnknownAttributeIgnored

Gets or sets a flag that indicates whether unknown XML properties and elements will be ignored without throwing an exception.

NonSerializableContent

Gets or sets the chart properties that will not be serialized.

SerializableContent

Gets or sets the chart properties that can be serialized.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetContentString(SerializationContents, Boolean)

Returns a serializable or non-serializable class and/or property names, depending on the specific flag value.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
Load(Stream)

Loads serialized data into the control from an object derived from the Stream class.

Load(String)

Loads serialized data saved to disk into the Chart control.

Load(TextReader)

Loads serialized data into the control from a reader object that derives from the TextReader class.

Load(XmlReader)

Loads serialized data into the control from an object derived from the XmlReader class.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Reset()

Resets all chart properties marked for serialization.

Save(Stream)

Saves chart data and properties with non-default values to an object that derives from the Stream class.

Save(String)

Saves chart data and properties with non-default values to the given file.

Save(TextWriter)

Saves chart data and properties with non-default values to the given object that is derived from the TextWriter class.

Save(XmlWriter)

Saves chart data and properties with non-default values to the given object that is derived from the XmlWriter class.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to