About IDataSource Binding
Binding is the persistent association between a Message object (the binder) and another object that exposes the appropriate interface (the bindee). When operations such as the SaveToObject and OpenObject methods are carried out, a binding is created at run time and is maintained after the operations are complete. After a binding has occurred, properties such as Source and SourceClass can be used to identify and access the interface on the currently bound object. The IsDirty property can be used to identify whether the content within the Message object has changed since the last rebinding or since it was last saved into the bound object. The Save method saves the content in the Message object into the currently bound object.
Each subsequent call to the OpenObject or SaveToObject method creates a new binding. These operations are similar to the Microsoft Word Open and SaveAs commands in the File menu:
- When you use the Open command in Word to open a file, the Word application is bound to the file on the file system. This works in essentially the same way as the IDataSource.OpenObject method does between a Message object and the other object. When you select Save, changes are saved to the currently bound file. Word checks what is essentially an ISDIRTY flag to determine whether the current contents are different that those within the file on the file system. When they are the same, the content within the application has an ISDIRTY flag equal to False. As soon as you change the content, the flag changes to True, which indicates that the user must save the document or lose the changes.
- When you use the Save As command in Word, you normally specify a new file name. The file contents are then written into a new file, and the application remains bound to that file; any subsequently saved versions of the contents go into the new file. This works in essentially the same way as the IDataSource.SaveToObject method does between a Message object and the other object.