FormatterServices::PopulateObjectMembers Method (Object^, array<MemberInfo^>^, array<Object^>^)

 

Populates the specified object with values for each field drawn from the data array of objects.

Namespace:   System.Runtime.Serialization
Assembly:  mscorlib (in mscorlib.dll)

public:
[SecurityCriticalAttribute]
static Object^ PopulateObjectMembers(
	Object^ obj,
	array<MemberInfo^>^ members,
	array<Object^>^ data
)

Parameters

obj
Type: System::Object^

The object to populate.

members
Type: array<System.Reflection::MemberInfo^>^

An array of MemberInfo that describes which fields and properties to populate.

data
Type: array<System::Object^>^

An array of Object that specifies the values for each field and property to populate.

Return Value

Type: System::Object^

The newly populated object.

Exception Condition
ArgumentNullException

The obj, members, or data parameter is null.

An element of members is null.

ArgumentException

The length of members does not match the length of data.

SerializationException

An element of members is not an instance of FieldInfo.

SecurityException

The caller does not have the required permission.

If an element in data is null, PopulateObjectMembers does not write anything to that field.

The following example creates an instance of a Book class and sets field values on the instance. The code then gets the type information using the GetSerializableMembers method. The code copies the instance data into an object array using the GetObjectData method. A new uninitialized instance of the class is created using the GetSafeUninitializedObject method. Finally, the data from the first instance is copied into the second instance using the PopulateObjectMembers method.

No code example is currently available or this language may not be supported.

SecurityPermission

For providing serialization services. Associated enumeration: SecurityPermissionFlag::SerializationFormatter, SecurityAction::LinkDemand.

.NET Framework
Available since 1.1
Return to top
Show: