ICustomObjectResolver.WriteFromStream

Syntax

WriteFromStream(Stream: IIOStream);

Parameters

Stream. The stream, from which data for write is obtained.

Description

The WriteFromStream method writes data to custom object from the stream.

Comments

To read data from the custom object to the stream, use the ICustomObjectResolver.ReadToStream method.

Example

Executing the example requires that the file system contains the C:\CustomObjData.pefx update file. This file must contain a custom object, in which any data is written. It is also required to have the C:\From.txt text file containing data that must be written to custom object.

Add links to the IO, Metabase system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    Update: IMetabaseUpdate;
    Progress: MyUpdateProgress;
Begin
    // Get the current repository
    Mb := MetabaseClass.Active;
    // Create an update
    Update := Mb.CreateUpdate;
    // Load update parameters from file
    Update.LoadFromFileNF("C:\CustomObjData.pefx");
    // Create an object that implements events that occur during update
    Progress := New MyUpdateProgress.Create;
    // Execute update
    Update.ApplyEx(Progress, Null);
End Sub UserProc;

// Class that implements events that occur during update
Class MyUpdateProgress: UpdateProgress
    // Event that occurs after applying custom object update,
    // but before it is saved to repository
    Sub OnAfterApplyCustomObject(Resolver: ICustomObjectResolver);
    Var
        StreamR, StreamW: IFileStream;
    Begin
        // Create a stream related with the text file C:\To.txt
        StreamR := New FileStream.Create("C:\To.txt", FileOpenMode.Create, FileShare.DenyNone);
        // Read data from custom object to the stream related with file
        Resolver.ReadToStream(StreamR);
        // Create a stream related with the text file C:\From.txt
        StreamW := New FileStream.Create("C:\From.txt", FileOpenMode.Read, FileShare.DenyNone);
        // Write data to custom object from the stream related with files
        Resolver.WriteFromStream(StreamW);
    End Sub OnAfterApplyCustomObject;
    
End Class MyUpdateProgress;

After executing the example the C:\CustomObjData.pefx update is applied. Use the stream to load data from the custom object in the update to the C:\To.txt file, and data from the C:\From.txt file is written to the object.

See also:

ICustomObjectResolver