C# Class Jot.StateTracker

A StateTracker is an object responsible for tracking the specified properties of the specified target objects. Tracking means persisting the values of the specified object properties, and restoring this data when appropriate.
Mostrar archivo Open project: anakic/Jot Class Usage Examples

Public Methods

Method Description
Configure ( object target ) : TrackingConfiguration

Gets or creates a configuration object what will control how the target object is going to be tracked (which properties, when to persist, when to apply, validation). For a given target object, always returns the same configuration instance.

RegisterConfigurationInitializer ( IConfigurationInitializer cfgInitializer ) : void

Registers an object that will initialize the configuration for all instances of a type.

Only the most specific initialier will be used (for the most derived type). E.g. if there are initializers for types Window and Object, and a window is being tracked, only the Window initializer will be used.

RunAutoPersist ( ) : void

Runs a global persist for all objects that are still alive and have AutoPersistEnabled=true in their TrackingConfiguration.

StateTracker ( ) : System

Creates a StateTracker that uses json files in a per-user folder to store the data. Does a global persist when it detects the desktop application is closing.

This constructor is appropriate for most desktop application use cases. Both ObjectStoreFactory and AutoPersistTrigger properties can be set/modified.

StateTracker ( IStoreFactory storeFactory, ITriggerPersist persistTrigger ) : System

Creates a new instance of the state tracker with the specified storage mechanism, and global persist trigger.

Even though both arguments can be set via properties, this constructor is here to make the dependencies explicit.

Private Methods

Method Description
AutoPersistTrigger_PersistRequired ( object sender, EventArgs e ) : void

Method Details

Configure() public method

Gets or creates a configuration object what will control how the target object is going to be tracked (which properties, when to persist, when to apply, validation). For a given target object, always returns the same configuration instance.
public Configure ( object target ) : TrackingConfiguration
target object The object whose properties your want to track.
return TrackingConfiguration

RegisterConfigurationInitializer() public method

Registers an object that will initialize the configuration for all instances of a type.
Only the most specific initialier will be used (for the most derived type). E.g. if there are initializers for types Window and Object, and a window is being tracked, only the Window initializer will be used.
public RegisterConfigurationInitializer ( IConfigurationInitializer cfgInitializer ) : void
cfgInitializer IConfigurationInitializer The configuration initializer to register.
return void

RunAutoPersist() public method

Runs a global persist for all objects that are still alive and have AutoPersistEnabled=true in their TrackingConfiguration.
public RunAutoPersist ( ) : void
return void

StateTracker() public method

Creates a StateTracker that uses json files in a per-user folder to store the data. Does a global persist when it detects the desktop application is closing.
This constructor is appropriate for most desktop application use cases. Both ObjectStoreFactory and AutoPersistTrigger properties can be set/modified.
public StateTracker ( ) : System
return System

StateTracker() public method

Creates a new instance of the state tracker with the specified storage mechanism, and global persist trigger.
Even though both arguments can be set via properties, this constructor is here to make the dependencies explicit.
public StateTracker ( IStoreFactory storeFactory, ITriggerPersist persistTrigger ) : System
storeFactory IStoreFactory The factory that will create an IStore for each tracked object's data.
persistTrigger ITriggerPersist The object that will notify the state tracker when it should run a global persist operation. This will usually be when the application is shutting down.
return System