แก้ไข

แชร์ผ่าน


FormatterServices.GetSerializableMembers Method

Definition

Returns all the serializable members for a particular class.

Overloads

GetSerializableMembers(Type)

Gets all the serializable members for a class of the specified Type.

GetSerializableMembers(Type, StreamingContext)

Gets all the serializable members for a class of the specified Type and in the provided StreamingContext.

GetSerializableMembers(Type)

Source:
FormatterServices.cs
Source:
FormatterServices.cs
Source:
FormatterServices.cs
Source:
FormatterServices.cs

Gets all the serializable members for a class of the specified Type.

public:
 static cli::array <System::Reflection::MemberInfo ^> ^ GetSerializableMembers(Type ^ type);
public static System.Reflection.MemberInfo[] GetSerializableMembers (Type type);
[System.Security.SecurityCritical]
public static System.Reflection.MemberInfo[] GetSerializableMembers (Type type);
static member GetSerializableMembers : Type -> System.Reflection.MemberInfo[]
[<System.Security.SecurityCritical>]
static member GetSerializableMembers : Type -> System.Reflection.MemberInfo[]
Public Shared Function GetSerializableMembers (type As Type) As MemberInfo()

Parameters

type
Type

The type being serialized.

Returns

An array of type MemberInfo of the non-transient, non-static members.

Attributes

Exceptions

The type parameter is null.

The caller does not have the required permission.

Remarks

Generally, the serializable members of a class are non-transient, non-static members such as fields and properties. To be included, properties must have both a getter and a setter. A class that implements the ISerializable interface or has a serialization surrogate does not have to serialize all these members, or can serialize additional members.

Because the GetSerializableMembers method calls the Type.GetFields method, it does not return fields in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which fields are returned.

See also

Applies to

GetSerializableMembers(Type, StreamingContext)

Source:
FormatterServices.cs
Source:
FormatterServices.cs
Source:
FormatterServices.cs
Source:
FormatterServices.cs

Gets all the serializable members for a class of the specified Type and in the provided StreamingContext.

public:
 static cli::array <System::Reflection::MemberInfo ^> ^ GetSerializableMembers(Type ^ type, System::Runtime::Serialization::StreamingContext context);
public static System.Reflection.MemberInfo[] GetSerializableMembers (Type type, System.Runtime.Serialization.StreamingContext context);
[System.Security.SecurityCritical]
public static System.Reflection.MemberInfo[] GetSerializableMembers (Type type, System.Runtime.Serialization.StreamingContext context);
static member GetSerializableMembers : Type * System.Runtime.Serialization.StreamingContext -> System.Reflection.MemberInfo[]
[<System.Security.SecurityCritical>]
static member GetSerializableMembers : Type * System.Runtime.Serialization.StreamingContext -> System.Reflection.MemberInfo[]
Public Shared Function GetSerializableMembers (type As Type, context As StreamingContext) As MemberInfo()

Parameters

type
Type

The type being serialized or cloned.

context
StreamingContext

The context where the serialization occurs.

Returns

An array of type MemberInfo of the non-transient, non-static members.

Attributes

Exceptions

The type parameter is null.

The caller does not have the required permission.

Remarks

Generally, the serializable members of a class are non-transient, non-static members such as fields and properties. To be included, properties must have both a getter and a setter. A class that implements ISerializable or has a serialization surrogate does not have to serialize all these members, or can serialize additional members.

If context includes the StreamingContextStates.Clone enumeration value, transient fields are also included in the MemberInfo array returned by this method.

Because the GetSerializableMembers method calls the Type.GetFields method, it does not return fields in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which fields are returned.

See also

Applies to