/// <summary>
 /// Engine calls this method to tell this type that it has loaded this type.
 /// The type should hook up to EngineCleanup event so that when that event is called, this type can flush all resources it has cached.
 /// Engine raises this event when it has finished a session run.
 /// </summary>
 /// <param name="host">Host, whose EngineCleanup event which we should handle when this type should reinitialize</param>
 public static void EngineCleanupHandler(ResourceStaticAnalysisEngine host)
 {
     //Implementation of ClassificationObject should provide its own override for this method (using 'new' keyword)
     //if it contains static resources that grow over time. This way the engine has a way to tell this implementation to free its resources
     //when the engine reinitializes.
     //You can do it by adding a hander such as the following:
     //engineCleanupAction += MyCleanupMethod;
     //And reset your static resources to initial state.
 }
        /// <summary>
        /// Creates an instance of EngineMonitor for the given engine.
        /// </summary>
        /// <param name="engine">ResourceStaticAnalysisEngine object to be monitored</param>
        internal EngineMonitor(ResourceStaticAnalysisEngine engine)
        {
            this._engine        = engine;
            LogExceptionDetails = false;

            Reset();

            #region Registering for engine events
            engine.LoadingStarting += (s, e) => loadingStart = DateTime.Now;
            engine.LoadingFinished += (s, countArgs) => { loadingEnd = DateTime.Now; objectsLoaded = countArgs.Value; };

            engine.ProcessingStarting += (s, e) => processingStart = DateTime.Now;
            engine.ProcessingFinished += (s, e) => processingEnd = DateTime.Now;

            engine.OutputStarting += (s, e) => outputStart = DateTime.Now;
            engine.OutputFinished += (s, e) => outputEnd = DateTime.Now;

            engine.EngineCleanup += (s, e) => this.Reset();
            #endregion
        }
 /// <summary>
 /// Make sure to call base implementation first, as it may perform some cleanup for the base class.
 /// ResourceStaticAnalysis calls this method once
 /// for each type when the first instance of the type is loaded. In this method
 /// you can register any cleanup code you want to run with the ResourceStaticAnalysis.EngineCleanup event.
 /// This cleanup code IS NOT for instances of Classification Objects but for the entire type - i.e.
 /// if you have static fields that cache data you may want to register them for cleanup so in case engine
 /// runs multiple times they can be reset between the multiple runs.
 /// </summary>
 /// <param name="engine">ResourceStaticAnalysis instance for which cleanup we want to listen.</param>
 public virtual void RegisterTypeForEngineCleanup(ResourceStaticAnalysisEngine engine)
 {
 }