Example #1
0
        public StateTracker(IObjectStore objectStore, ITriggerPersist globalAutoPersistTrigger)
        {
            ObjectStore = objectStore;
            AutoPersistTrigger = globalAutoPersistTrigger;

            if (AutoPersistTrigger != null)
                AutoPersistTrigger.PersistRequired += (s, e) => RunAutoPersist();
        }
Example #2
0
        /// <summary>
        /// Creates a new instance of the state tracker with the specified storage mechanism, and global persist trigger.
        /// </summary>
        /// <remarks>
        /// Even though both arguments can be set via properties, this constructor is here to make the dependencies explicit.
        /// </remarks>
        /// <param name="storeFactory">The factory that will create an IStore for each tracked object's data.</param>
        /// <param name="persistTrigger">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.</param>
        public StateTracker(IStoreFactory storeFactory, ITriggerPersist persistTrigger)
        {
            StoreFactory       = storeFactory;
            AutoPersistTrigger = persistTrigger;

            //add the basic configuration initializers
            RegisterConfigurationInitializer(new DefaultConfigurationInitializer()); //the default, will be used for all objects that don't have a more specific initializer
            RegisterConfigurationInitializer(new FormConfigurationInitializer());    //will be used for initializing configuration for forms (WinForms)
            RegisterConfigurationInitializer(new WindowConfigurationInitializer());  //will be used for initializing configuration for windows (WPF)
        }
Example #3
0
        public StateTracker(IObjectStore objectStore, ITriggerPersist globalAutoPersistTrigger)
        {
            ObjectStore        = objectStore;
            AutoPersistTrigger = globalAutoPersistTrigger;

            if (AutoPersistTrigger != null)
            {
                AutoPersistTrigger.PersistRequired += (s, e) => RunAutoPersist();
            }
        }
Example #4
0
        /// <summary>
        /// Creates a new instance of the state tracker with the specified storage mechanism, and global persist trigger. 
        /// </summary>
        /// <remarks>
        /// Even though both arguments can be set via properties, this constructor is here to make the dependencies explicit.
        /// </remarks>
        /// <param name="storeFactory">The factory that will create an IStore for each tracked object's data.</param>
        /// <param name="persistTrigger">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.</param>
        public StateTracker(IStoreFactory storeFactory, ITriggerPersist persistTrigger)
        {
            StoreFactory = storeFactory;
            AutoPersistTrigger = persistTrigger;

            //add the basic configuration initializers
            RegisterConfigurationInitializer(new DefaultConfigurationInitializer()); //the default, will be used for all objects that don't have a more specific initializer
            RegisterConfigurationInitializer(new FormConfigurationInitializer());    //will be used for initializing configuration for forms (WinForms)
            RegisterConfigurationInitializer(new WindowConfigurationInitializer());  //will be used for initializing configuration for windows (WPF)
        }
        internal TrackingConfiguration(object target, StateTracker tracker)
        {
            StateTracker         = tracker;
            this.TargetReference = new WeakReference(target);
            TrackedProperties    = new Dictionary <string, TrackedPropertyDescriptor>();
            AutoPersistEnabled   = true;
            AddMetaData();

            ITrackingAware trackingAwareTarget = target as ITrackingAware;

            if (trackingAwareTarget != null)
            {
                trackingAwareTarget.InitConfiguration(this);
            }

            ITriggerPersist asNotify = target as ITriggerPersist;

            if (asNotify != null)
            {
                asNotify.PersistRequired += (s, e) => Persist();
            }
        }