This interface that is implemented by objects that are partually persisted.
Syntax
| Visual Basic (Declaration) | |
|---|
Public Interface IPartialPersist |
| C# | |
|---|
public interface IPartialPersist |
| Managed Extensions for C++ | |
|---|
public __gc __interface IPartialPersist |
| C++/CLI | |
|---|
public interface class IPartialPersist |
Example
The following example shows how to implement the interface and use it in combination
with the
IObjectNotification interface.
| C# | Copy Code |
|---|
[Persistent("Users")] public sealed class User : IPartialPersist, IObjectNotification { private Dictionary<string, bool> _changes; private string _name; [Field("Name")] public string Name { get { return _name; } set { _name = value; // Signalize that the property has changed. SignalizeChange("Name"); } } // ... Other properties of the persistent. // Signalizes that a property with the given name has been changed. private void SignalizeChange(string propertyName) { // Adds the changed property to the dictionary. if (_changes != null && !_changes.ContainsKey(propertyName)) _changes.Add(propertyName, true); } #region IObjectNotification Members void IObjectNotification.OnAfterPopulated(ObjectNotificationEventArgs e) { // Initializes the dictionary holding the changes after having // finished to populate the persistent object. _changes = new Dictionary<string, bool>(); } // ... Other methods of the interface. #endregion #region IPartialPersist Members // Returns whether a member is to persist. bool IPartialPersist.IsMemberToPersist(string name, PersistentOperations operation) { // Returns if whether the dictionary contains the property. return _changes.ContainsKey(name); } // Gets whether the persistent instance has members to persist. bool IPartialPersist.HasMembersToPersist { get { return _changes.Count > 0; } } #endregion } |
Remarks
Requirements
Namespace: Chili.Opf3
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: Chili.Opf3 (in Chili.Opf3.dll)
See Also