Szerkesztés

Megosztás a következőn keresztül:


Persistent Object Interfaces

A persistent object implements one or more persistent object interfaces. Clients use persistent object interfaces to tell those objects when and where to store their state. All persistent object interfaces are derived from IPersist, so any object that implements any persistent object interface also implements IPersist.

The following persistent object interfaces are currently defined:

Implementers choose which persistent object interfaces an object supports depending on how the object is to be used. By not supporting any persistent object interfaces, the implementer is effectively saying, "This object's state cannot be persistently stored." By supporting one or more persistent object interfaces, the implementer is effectively saying, "This object's state can be persistently stored in one or more data store mediums."

For example, the following table lists several object types that allow support for different persistent object interfaces.

Category Persistent object interfaces typically supported
Monikers
IPersistStream
OLE embeddable objects
IPersistStorage, IPersistFile
ActiveX controls
IPersistStreamInit, IPersistStorage, IPersistMemory, IPersistPropertyBag, IPersistMoniker
ActiveX document objects
IPersistStorage, IPersistFile

Client implementers can also choose which persistent object interfaces the client can use. The interfaces a client uses is usually determined by where the client can store its own data. A client that can store its data only in a flat file will probably use only IPersistStreamInit, IPersistMoniker, and IPersistPropertyBag. (IPersistStreamInit can replace IPersistStream in most applications, because it contains that definition and adds an initialization method.) A client that can save its data to a structured storage file will, in addition, use IPersistStorage.

Initializing Persistent Objects