Loop through the objects to save. For each top-level object, perform the following steps.
Use the DirectXFileSave.CreateDataObject method to create a DirectXFileData object as a top-level object in the file. If the top-level data object has optional child objects, add them to the object by using the appropriate method as defined in the next step.
Each DirectXFileData object can have optional child objects if its template allows it. The child objects can be any of the three types of objects: DirectXFileData, DirectXFileReference, or DirectXFileBinary. Loop through the objects you need to save, adding each optional child member to the object list in the manner appropriate to its type, as illustrated in the following steps. Then, if the object type is Data, call the DirectXFileSave.CreateDataObject method to create an DirectXFileData object, and then call the DirectXFileData.AddDataObject method to add it as a child of the object. If the object type is Data Reference, call the DirectXFileData.AddDataReference method to create and add the data reference object as a child of the object. Or, if the object type is Binary, call the DirectXFileData.AddBinaryObject method to create and add the binary object as a child of the object.